trackguard 0.22.0 → 0.23.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/app/controllers/concerns/trackguard/page_tracker.rb +2 -1
- data/app/controllers/trackguard/page_views_controller.rb +1 -1
- data/app/views/layouts/trackguard/admin.html.erb +1 -1
- data/lib/trackguard/adapters/base.rb +15 -1
- data/lib/trackguard/adapters/local.rb +14 -11
- data/lib/trackguard/version.rb +1 -1
- data/lib/trackguard.rb +3 -3
- metadata +1 -2
- data/app/services/trackguard/page_view_recorder.rb +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9679d1fece905062d49d0789b97991df9929a29631f1e62d8be8579ae21b31e
|
|
4
|
+
data.tar.gz: 45ebfd5abf74a9f45818e52c7145b63870ee89f6f6719acf0815c6c144a7b851
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9ab1e295683445413142c92b806a21af5be5b1626e0958396432184737754bcd1ca1a543812c805a529113d3ac4a9371706b977800d4ad41a850c5dd1990408
|
|
7
|
+
data.tar.gz: 51a312f728842ff3ef097cfbc719895c38cbc4542e78d61fa57fd1ee6ec1b3edc7d8281faf713a34bc7e301629ef74025bd3c6b7debc2779ae51ff1cf24fdf11
|
|
@@ -22,7 +22,7 @@ module Trackguard
|
|
|
22
22
|
return unless request.get? || request.head?
|
|
23
23
|
return unless request.format.html?
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Trackguard.adapter.track_page_view(
|
|
26
26
|
path: request.path,
|
|
27
27
|
ip: request.remote_ip,
|
|
28
28
|
user_agent: request.user_agent.to_s,
|
|
@@ -30,6 +30,7 @@ module Trackguard
|
|
|
30
30
|
session_id: session.id.to_s,
|
|
31
31
|
trace_id: @trace_id,
|
|
32
32
|
source: extract_source,
|
|
33
|
+
initial: false,
|
|
33
34
|
http_method: request.request_method
|
|
34
35
|
)
|
|
35
36
|
end
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
Trackguard
|
|
16
16
|
</span>
|
|
17
17
|
|
|
18
|
-
<a class="tg-back-link" href="<%= Trackguard.
|
|
18
|
+
<a class="tg-back-link" href="<%= Trackguard.admin_path %>">
|
|
19
19
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" aria-hidden="true">
|
|
20
20
|
<path stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
|
|
21
21
|
stroke-linejoin="round" fill="none" d="M10.5 3.5L5.5 8l5 4.5"/>
|
|
@@ -8,12 +8,26 @@ module Trackguard
|
|
|
8
8
|
def flagged_visitor?(ip) = raise NotImplementedError, "#{self.class}#flagged_visitor?"
|
|
9
9
|
|
|
10
10
|
def track_page_view(path:, ip:, user_agent:, referer:, session_id:, trace_id:, source:, initial:, http_method:)
|
|
11
|
-
|
|
11
|
+
return if blocked_user_agent?(user_agent)
|
|
12
|
+
return if path.blank? || path.start_with?(Trackguard.admin_path)
|
|
13
|
+
|
|
14
|
+
perform_track_page_view(
|
|
15
|
+
path: path, ip: ip, user_agent: user_agent, referer: referer,
|
|
16
|
+
session_id: session_id, trace_id: trace_id, source: source,
|
|
17
|
+
initial: initial, http_method: http_method
|
|
18
|
+
)
|
|
12
19
|
end
|
|
13
20
|
|
|
14
21
|
def track_blocked_request(ip:, user_agent:, path:, http_method:, block_reason:)
|
|
15
22
|
raise NotImplementedError, "#{self.class}#track_blocked_request"
|
|
16
23
|
end
|
|
24
|
+
|
|
25
|
+
protected
|
|
26
|
+
|
|
27
|
+
def perform_track_page_view(path:, ip:, user_agent:, referer:, session_id:, trace_id:, source:, initial:,
|
|
28
|
+
http_method:)
|
|
29
|
+
raise NotImplementedError, "#{self.class}#perform_track_page_view"
|
|
30
|
+
end
|
|
17
31
|
end
|
|
18
32
|
end
|
|
19
33
|
end
|
|
@@ -15,7 +15,20 @@ module Trackguard
|
|
|
15
15
|
Visitor.flagged?(ip)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def
|
|
18
|
+
def track_blocked_request(ip:, user_agent:, path:, http_method:, block_reason:)
|
|
19
|
+
TrackBlockedRequestJob.perform_later(
|
|
20
|
+
ip: ip,
|
|
21
|
+
user_agent: user_agent,
|
|
22
|
+
path: path,
|
|
23
|
+
http_method: http_method,
|
|
24
|
+
block_reason: block_reason
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
protected
|
|
29
|
+
|
|
30
|
+
def perform_track_page_view(path:, ip:, user_agent:, referer:, session_id:, trace_id:, source:, initial:,
|
|
31
|
+
http_method:)
|
|
19
32
|
TrackPageViewJob.perform_later(
|
|
20
33
|
path: path,
|
|
21
34
|
ip: ip,
|
|
@@ -28,16 +41,6 @@ module Trackguard
|
|
|
28
41
|
http_method: http_method
|
|
29
42
|
)
|
|
30
43
|
end
|
|
31
|
-
|
|
32
|
-
def track_blocked_request(ip:, user_agent:, path:, http_method:, block_reason:)
|
|
33
|
-
TrackBlockedRequestJob.perform_later(
|
|
34
|
-
ip: ip,
|
|
35
|
-
user_agent: user_agent,
|
|
36
|
-
path: path,
|
|
37
|
-
http_method: http_method,
|
|
38
|
-
block_reason: block_reason
|
|
39
|
-
)
|
|
40
|
-
end
|
|
41
44
|
end
|
|
42
45
|
end
|
|
43
46
|
end
|
data/lib/trackguard/version.rb
CHANGED
data/lib/trackguard.rb
CHANGED
|
@@ -8,7 +8,7 @@ require "trackguard/adapters/local"
|
|
|
8
8
|
|
|
9
9
|
module Trackguard
|
|
10
10
|
class << self
|
|
11
|
-
attr_writer :authenticate_admin_with, :admin_layout, :
|
|
11
|
+
attr_writer :authenticate_admin_with, :admin_layout, :admin_path, :back_label, :api_token, :throttle_limit,
|
|
12
12
|
:throttle_period
|
|
13
13
|
|
|
14
14
|
def authenticate_admin_with
|
|
@@ -19,8 +19,8 @@ module Trackguard
|
|
|
19
19
|
@admin_layout ||= "trackguard/admin"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
@
|
|
22
|
+
def admin_path
|
|
23
|
+
@admin_path ||= "/admin"
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def back_label
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trackguard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.23.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Krzysztof Rygielski
|
|
@@ -68,7 +68,6 @@ files:
|
|
|
68
68
|
- app/models/trackguard/whitelisted_ip.rb
|
|
69
69
|
- app/services/trackguard/analytics_query.rb
|
|
70
70
|
- app/services/trackguard/application_service.rb
|
|
71
|
-
- app/services/trackguard/page_view_recorder.rb
|
|
72
71
|
- app/views/layouts/trackguard/admin.html.erb
|
|
73
72
|
- app/views/trackguard/admin/_nav.html.erb
|
|
74
73
|
- app/views/trackguard/admin/_stats_panel.html.erb
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module Trackguard
|
|
2
|
-
class PageViewRecorder < ApplicationService
|
|
3
|
-
def initialize(path:, ip:, user_agent:, referer:, session_id:, trace_id:, source: nil, initial: false,
|
|
4
|
-
http_method: nil)
|
|
5
|
-
@path = path.to_s
|
|
6
|
-
@ip = ip
|
|
7
|
-
@user_agent = user_agent.to_s
|
|
8
|
-
@referer = referer
|
|
9
|
-
@session_id = session_id
|
|
10
|
-
@trace_id = trace_id
|
|
11
|
-
@source = source.presence
|
|
12
|
-
@initial = initial
|
|
13
|
-
@http_method = http_method
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def call
|
|
17
|
-
adapter = Trackguard.adapter
|
|
18
|
-
return if adapter.blocked_user_agent?(@user_agent)
|
|
19
|
-
return if @path.blank? || @path.start_with?("/admin")
|
|
20
|
-
|
|
21
|
-
adapter.track_page_view(
|
|
22
|
-
path: @path,
|
|
23
|
-
ip: @ip,
|
|
24
|
-
user_agent: @user_agent,
|
|
25
|
-
referer: @referer,
|
|
26
|
-
session_id: @session_id,
|
|
27
|
-
trace_id: @trace_id,
|
|
28
|
-
source: @source,
|
|
29
|
-
initial: @initial,
|
|
30
|
-
http_method: @http_method
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|