effective_logging 4.4.2 → 4.4.4
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/datatables/effective_logs_datatable.rb +7 -1
- data/app/models/effective_logger.rb +9 -7
- data/config/effective_logging.rb +14 -0
- data/lib/effective_logging/active_storage_logger.rb +28 -8
- data/lib/effective_logging/engine.rb +15 -2
- data/lib/effective_logging/log_page_views.rb +3 -2
- data/lib/effective_logging/version.rb +1 -1
- data/lib/effective_logging.rb +15 -1
- metadata +24 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 851e006a4e16dae68158ad50881517b9db428d79c18a92ed96b319ab9e9421bd
|
|
4
|
+
data.tar.gz: 94a02d91107f1ee8d1a2cb6e99195652e3890d053400ed152e21a3b2a997db57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 38a439e843773d92bc8369bd1adc0096d7bb4f7303fcafbd70541da7ad7e581bbc865c38dfce9c29d8749ded007bfa3b3ae1b437e6405b5ae67be4ee09830b34
|
|
7
|
+
data.tar.gz: 7621c6b709fb7bdef5a6d26002df489490dc0cba65efc4b96a22ffa5ccb9e79193346a30e90b3cc770b4ddef39cf4a95a6a90699046dc381ef991713ef5713d9
|
|
@@ -26,7 +26,13 @@ class EffectiveLogsDatatable < Effective::Datatable
|
|
|
26
26
|
|
|
27
27
|
col :associated_type, visible: false, sort: false
|
|
28
28
|
col :associated_id, visible: false, label: 'Associated Id', sort: false
|
|
29
|
-
col :associated_to_s, label: '
|
|
29
|
+
col :associated_to_s, label: 'Item'
|
|
30
|
+
|
|
31
|
+
col(:associated, visible: false).search do |collection, term, column, sql_column|
|
|
32
|
+
collection.where("associated_to_s ILIKE ?", "%#{term}%")
|
|
33
|
+
end.sort do |collection, direction, column, sql_column|
|
|
34
|
+
collection.order(associated_to_s: direction)
|
|
35
|
+
end
|
|
30
36
|
|
|
31
37
|
col :message, sort: false do |log|
|
|
32
38
|
(log.message || '').gsub("\n", '<br>')
|
|
@@ -17,22 +17,24 @@ class EffectiveLogger
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
if options[:request].present? && options[:request].respond_to?(:referrer)
|
|
20
|
-
request = options
|
|
20
|
+
request = options[:request]
|
|
21
21
|
|
|
22
22
|
options[:ip] ||= request.ip
|
|
23
23
|
options[:referrer] ||= request.referrer
|
|
24
24
|
options[:user_agent] ||= request.user_agent
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
details = options.except(:request, :user_id, :user_type, :user, :associated_id, :associated_type, :associated, :associated_to_s)
|
|
28
|
+
|
|
27
29
|
log = EffectiveLogging.Log.new(
|
|
28
30
|
message: message,
|
|
29
31
|
status: status,
|
|
30
|
-
user_id: options
|
|
31
|
-
user_type: options
|
|
32
|
-
user: options
|
|
33
|
-
associated: options
|
|
34
|
-
associated_to_s: options
|
|
35
|
-
details:
|
|
32
|
+
user_id: options[:user_id],
|
|
33
|
+
user_type: options[:user_type],
|
|
34
|
+
user: options[:user],
|
|
35
|
+
associated: options[:associated],
|
|
36
|
+
associated_to_s: options[:associated_to_s],
|
|
37
|
+
details: details
|
|
36
38
|
)
|
|
37
39
|
|
|
38
40
|
if log.associated.present?
|
data/config/effective_logging.rb
CHANGED
|
@@ -17,6 +17,20 @@ EffectiveLogging.setup do |config|
|
|
|
17
17
|
# Log all active storage downloads
|
|
18
18
|
config.active_storage_enabled = true
|
|
19
19
|
|
|
20
|
+
# Only log active storage downloads for these attachment record types
|
|
21
|
+
# config.active_storage_only = []
|
|
22
|
+
|
|
23
|
+
# Don't log active storage downloads for these attachment record types
|
|
24
|
+
# config.active_storage_except = [
|
|
25
|
+
# 'ActionText::RichText'
|
|
26
|
+
# 'Effective::BannerAd',
|
|
27
|
+
# 'Effective::CarouselItem',
|
|
28
|
+
# 'Effective::PageBanner',
|
|
29
|
+
# 'Effective::PageSection',
|
|
30
|
+
# 'Effective::Permalink',
|
|
31
|
+
# 'Effective::Post',
|
|
32
|
+
# ]
|
|
33
|
+
|
|
20
34
|
# Log all sent emails
|
|
21
35
|
config.email_enabled = true
|
|
22
36
|
|
|
@@ -3,29 +3,49 @@
|
|
|
3
3
|
module EffectiveLogging
|
|
4
4
|
module ActiveStorageLogger
|
|
5
5
|
|
|
6
|
-
def
|
|
7
|
-
|
|
6
|
+
def track_active_storage_download
|
|
7
|
+
@blob || set_download_blob()
|
|
8
|
+
track_active_storage_blob(@blob)
|
|
9
|
+
end
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
def track_active_storage_redirect
|
|
12
|
+
@blob || set_blob()
|
|
13
|
+
track_active_storage_blob(@blob)
|
|
14
|
+
end
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
return unless key.present?
|
|
13
|
-
return if (key[:content_type] || '').starts_with?('image')
|
|
16
|
+
private
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
def track_active_storage_blob(blob)
|
|
19
|
+
return if EffectiveLogging.supressed?
|
|
16
20
|
return unless blob.present?
|
|
17
21
|
|
|
22
|
+
onlies = EffectiveLogging.active_storage_onlies
|
|
23
|
+
excepts = EffectiveLogging.active_storage_excepts
|
|
24
|
+
|
|
18
25
|
blob.attachments.each do |attachment|
|
|
19
26
|
next if attachment.name == 'embeds'
|
|
20
|
-
next if attachment.record_type
|
|
27
|
+
next if attachment.record_type.blank?
|
|
28
|
+
|
|
29
|
+
# Process except and only
|
|
30
|
+
next if excepts.present? && excepts.any? { |type| attachment.record_type.start_with?(type) || attachment.record_type.end_with?(type) }
|
|
31
|
+
next if onlies.present? && !onlies.any? { |type| attachment.record_type.start_with?(type) || attachment.record_type.end_with?(type) }
|
|
21
32
|
|
|
22
33
|
associated = attachment.record
|
|
23
34
|
filename = blob.filename.to_s
|
|
24
35
|
message = [associated.to_s, filename.to_s].uniq.join(' ')
|
|
36
|
+
user = current_user
|
|
25
37
|
|
|
26
38
|
EffectiveLogger.download(message, associated: associated, associated_to_s: filename, filename: filename, user: user)
|
|
27
39
|
end
|
|
28
40
|
end
|
|
29
41
|
|
|
42
|
+
def set_download_blob
|
|
43
|
+
@blob ||= ActiveStorage::Blob.where(key: decode_verified_key().try(:dig, :key)).first
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def current_user
|
|
47
|
+
(defined?(Tenant) ? send("current_#{Tenant.current}_user") : super)
|
|
48
|
+
end
|
|
49
|
+
|
|
30
50
|
end
|
|
31
51
|
end
|
|
@@ -38,8 +38,21 @@ module EffectiveLogging
|
|
|
38
38
|
initializer 'effective_logging.active_storage' do |app|
|
|
39
39
|
if EffectiveLogging.active_storage_enabled == true && defined?(ActiveStorage)
|
|
40
40
|
app.config.to_prepare do
|
|
41
|
-
ActiveStorage::
|
|
42
|
-
|
|
41
|
+
ActiveStorage::BaseController.class_eval do
|
|
42
|
+
include ActiveStorageLogger
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
ActiveStorage::DiskController.class_eval do
|
|
46
|
+
after_action :track_active_storage_download, only: [:show]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
ActiveStorage::Blobs::RedirectController.class_eval do
|
|
50
|
+
after_action :track_active_storage_redirect, only: [:show]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
ActiveStorage::Representations::RedirectController.class_eval do
|
|
54
|
+
after_action :track_active_storage_redirect, only: [:show]
|
|
55
|
+
end
|
|
43
56
|
end
|
|
44
57
|
end
|
|
45
58
|
end
|
|
@@ -42,14 +42,15 @@ module EffectiveLogging
|
|
|
42
42
|
user = EffectiveLogging.current_user || (current_user if respond_to?(:current_user))
|
|
43
43
|
|
|
44
44
|
if self.class.log_page_views_opts[:details] == false
|
|
45
|
-
::EffectiveLogger.view("#{request.request_method} #{request.path}", user: user)
|
|
45
|
+
::EffectiveLogger.view("#{request.request_method} #{request.path}", user: user, associated: try(:resource))
|
|
46
46
|
else
|
|
47
47
|
::EffectiveLogger.view(
|
|
48
48
|
"#{request.request_method} #{request.path}",
|
|
49
49
|
user: user,
|
|
50
50
|
format: (request.format.to_s == 'text/html' ? nil : request.format.to_s),
|
|
51
51
|
params: request.filtered_parameters.reject { |k, v| (k == 'controller' || k == 'action') },
|
|
52
|
-
request: request
|
|
52
|
+
request: request,
|
|
53
|
+
associated: try(:resource)
|
|
53
54
|
)
|
|
54
55
|
end
|
|
55
56
|
end
|
data/lib/effective_logging.rb
CHANGED
|
@@ -7,7 +7,8 @@ module EffectiveLogging
|
|
|
7
7
|
[
|
|
8
8
|
:logs_table_name, :tracks_table_name, :layout, :additional_statuses,
|
|
9
9
|
:log_class_name,
|
|
10
|
-
:active_storage_enabled, :
|
|
10
|
+
:active_storage_enabled, :active_storage_only, :active_storage_except,
|
|
11
|
+
:email_enabled, :sign_in_enabled, :sign_out_enabled
|
|
11
12
|
]
|
|
12
13
|
end
|
|
13
14
|
|
|
@@ -66,4 +67,17 @@ module EffectiveLogging
|
|
|
66
67
|
Thread.current[:effective_logging_supressed] == true
|
|
67
68
|
end
|
|
68
69
|
|
|
70
|
+
# For ActiveStorageLogger
|
|
71
|
+
def self.active_storage_onlies
|
|
72
|
+
onlies = Array(active_storage_only) - [nil, '', ' ']
|
|
73
|
+
raise("effective_logging.active_storage_only should be an Array of Strings") if onlies.present? && !onlies.all? { |type| type.kind_of?(String) }
|
|
74
|
+
onlies
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.active_storage_excepts
|
|
78
|
+
excepts = Array(active_storage_except) - [nil, '', ' ']
|
|
79
|
+
raise("effective_logging.active_storage_except should be an Array of Strings") if excepts.present? && !excepts.all? { |type| type.kind_of?(String) }
|
|
80
|
+
excepts
|
|
81
|
+
end
|
|
82
|
+
|
|
69
83
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: effective_logging
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.4.
|
|
4
|
+
version: 4.4.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Code and Effect
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: haml-rails
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: pry-byebug
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -123,7 +137,7 @@ dependencies:
|
|
|
123
137
|
- !ruby/object:Gem::Version
|
|
124
138
|
version: '0'
|
|
125
139
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name:
|
|
140
|
+
name: wicked
|
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
|
128
142
|
requirements:
|
|
129
143
|
- - ">="
|
|
@@ -137,7 +151,7 @@ dependencies:
|
|
|
137
151
|
- !ruby/object:Gem::Version
|
|
138
152
|
version: '0'
|
|
139
153
|
- !ruby/object:Gem::Dependency
|
|
140
|
-
name:
|
|
154
|
+
name: effective_test_bot
|
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
|
142
156
|
requirements:
|
|
143
157
|
- - ">="
|
|
@@ -151,19 +165,19 @@ dependencies:
|
|
|
151
165
|
- !ruby/object:Gem::Version
|
|
152
166
|
version: '0'
|
|
153
167
|
- !ruby/object:Gem::Dependency
|
|
154
|
-
name:
|
|
168
|
+
name: effective_developer
|
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
|
156
170
|
requirements:
|
|
157
|
-
- - "
|
|
171
|
+
- - ">="
|
|
158
172
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: '
|
|
173
|
+
version: '0'
|
|
160
174
|
type: :development
|
|
161
175
|
prerelease: false
|
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
|
163
177
|
requirements:
|
|
164
|
-
- - "
|
|
178
|
+
- - ">="
|
|
165
179
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: '
|
|
180
|
+
version: '0'
|
|
167
181
|
description: Automatically log all sent emails, user logins, and page views. This
|
|
168
182
|
also will log custom events from Ruby and JavaScript.
|
|
169
183
|
email:
|
|
@@ -229,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
229
243
|
- !ruby/object:Gem::Version
|
|
230
244
|
version: '0'
|
|
231
245
|
requirements: []
|
|
232
|
-
rubygems_version: 3.
|
|
246
|
+
rubygems_version: 3.5.9
|
|
233
247
|
signing_key:
|
|
234
248
|
specification_version: 4
|
|
235
249
|
summary: Automatically log all sent emails, user logins, and page views. This also
|