action_trace 0.3.0 → 0.4.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/interactors/action_trace/fetch_data_changes.rb +1 -1
- data/app/interactors/action_trace/fetch_page_visits.rb +1 -1
- data/app/interactors/action_trace/fetch_session_starts.rb +1 -1
- data/app/interactors/concerns/activity_log_fetchable.rb +3 -1
- data/app/models/action_trace/activity_log.rb +2 -1
- data/lib/action_trace/engine.rb +1 -8
- data/lib/action_trace/version.rb +1 -1
- data/lib/generators/action_trace/install/install_generator.rb +18 -0
- data/lib/generators/action_trace/views/views_generator.rb +4 -1
- metadata +1 -3
- data/lib/generators/action_trace/views/templates/views/action_trace/activity_logs/_index.html.erb +0 -7
- data/lib/generators/action_trace/views/templates/views/action_trace/activity_logs/index.html.erb +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8203cf9f2490c006cca8d9ce25fd692cfe5d06c576c44837733da34ec83f22e6
|
|
4
|
+
data.tar.gz: 77310c6e8c0f072dc2714f251d0db19d968fa3edf5c8d5ace62ffd9a4393218a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ec68b1545e8e87b327b2288b451ec69b8a864829341b7c6f163e17be14b0e868753c888c6dc81de3f31574eb2f6acecae17c1e806346dc07638b7f952cbcf52
|
|
7
|
+
data.tar.gz: 7152f64871c07d49360cd285f456376f6d5aeac054f7b35583249ed0f98c4ee9efc1e0fb1e89e3184a6d91fcfd81b43c486b65f2cba9f7965ab71fbf43ebe59c
|
|
@@ -19,7 +19,7 @@ module ActionTrace
|
|
|
19
19
|
id: "act_#{activity.id}",
|
|
20
20
|
source: source_type(activity),
|
|
21
21
|
occurred_at: activity.created_at,
|
|
22
|
-
user: activity.owner
|
|
22
|
+
user: activity.owner,
|
|
23
23
|
trackable_type: activity.trackable_type,
|
|
24
24
|
details: activity.parameters || {},
|
|
25
25
|
paper_trail_version: PaperTrail::Version.find_by(id: activity.version_id),
|
|
@@ -19,7 +19,7 @@ module ActionTrace
|
|
|
19
19
|
id: "visit_#{visit.id}",
|
|
20
20
|
source: 'session_start',
|
|
21
21
|
occurred_at: visit.started_at,
|
|
22
|
-
user: visit.user
|
|
22
|
+
user: visit.user,
|
|
23
23
|
subject: "#{visit.browser} on #{visit.os} (#{visit.ip})",
|
|
24
24
|
details: visit.attributes.slice('ip', 'browser', 'os', 'device_type', 'country', 'landing_page', 'user_agent')
|
|
25
25
|
}
|
|
@@ -21,8 +21,10 @@ module ActivityLogFetchable
|
|
|
21
21
|
if context.company_id.present?
|
|
22
22
|
scope = if model_class.respond_to?(:filter_by_company)
|
|
23
23
|
model_class.filter_by_company(scope, context.company_id)
|
|
24
|
-
|
|
24
|
+
elsif model_class.method_defined?(:company_id)
|
|
25
25
|
scope.where(company_id: context.company_id)
|
|
26
|
+
else
|
|
27
|
+
scope
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
@@ -6,7 +6,7 @@ module ActionTrace
|
|
|
6
6
|
include ActionTrace::ActivityLogPresenter
|
|
7
7
|
|
|
8
8
|
attr_reader :id, :source, :occurred_at, :user, :raw_subject, :details, :url, :paper_trail_version, :trackable,
|
|
9
|
-
:trackable_type
|
|
9
|
+
:trackable_type, :company
|
|
10
10
|
|
|
11
11
|
SOURCES = {
|
|
12
12
|
data_create: 'data_create',
|
|
@@ -28,6 +28,7 @@ module ActionTrace
|
|
|
28
28
|
@paper_trail_version = attributes[:paper_trail_version]
|
|
29
29
|
@trackable = attributes[:trackable]
|
|
30
30
|
@trackable_type = attributes[:trackable_type]
|
|
31
|
+
@company = attributes[:user]&.company if attributes[:user].respond_to?(:company)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def data_create?
|
data/lib/action_trace/engine.rb
CHANGED
|
@@ -24,13 +24,6 @@ module ActionTrace
|
|
|
24
24
|
user_ids = user_class.where(company_id: company_id).select(:id)
|
|
25
25
|
scope.where(owner_type: user_class.name, owner_id: user_ids)
|
|
26
26
|
end
|
|
27
|
-
|
|
28
|
-
[Ahoy::Visit, Ahoy::Event].each do |klass|
|
|
29
|
-
klass.define_singleton_method(:filter_by_company) do |scope, company_id|
|
|
30
|
-
user_ids = user_class.where(company_id: company_id).select(:id)
|
|
31
|
-
scope.where(user_id: user_ids)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
27
|
end
|
|
35
28
|
end
|
|
36
|
-
end
|
|
29
|
+
end
|
data/lib/action_trace/version.rb
CHANGED
|
@@ -30,6 +30,7 @@ module ActionTrace
|
|
|
30
30
|
|
|
31
31
|
def run_ahoy_install
|
|
32
32
|
generate 'ahoy:install' unless options[:skip_ahoy]
|
|
33
|
+
inject_ahoy_filter_by_company
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
def run_paper_trail_install
|
|
@@ -51,6 +52,23 @@ module ActionTrace
|
|
|
51
52
|
template 'initializers/action_trace.rb.tt', 'config/initializers/action_trace.rb'
|
|
52
53
|
end
|
|
53
54
|
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def inject_ahoy_filter_by_company
|
|
58
|
+
filter_method = <<~RUBY
|
|
59
|
+
|
|
60
|
+
def self.filter_by_company(scope, company_id)
|
|
61
|
+
scope.joins(:user).where(users: { company_id: company_id })
|
|
62
|
+
end
|
|
63
|
+
RUBY
|
|
64
|
+
|
|
65
|
+
%w[visit event].each do |model|
|
|
66
|
+
inject_into_file "app/models/ahoy/#{model}.rb", filter_method, before: " end\nend\n"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
public
|
|
71
|
+
|
|
54
72
|
def show_post_install_message
|
|
55
73
|
readme 'POST_INSTALL' if behavior == :invoke
|
|
56
74
|
end
|
|
@@ -15,7 +15,10 @@ module ActionTrace
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def copy_views
|
|
18
|
-
directory
|
|
18
|
+
directory(
|
|
19
|
+
File.expand_path('../../../../app/views/action_trace', __dir__),
|
|
20
|
+
'app/views/action_trace'
|
|
21
|
+
)
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
def copy_controller
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: action_trace
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- gimbaro
|
|
@@ -267,8 +267,6 @@ files:
|
|
|
267
267
|
- lib/generators/action_trace/install/install_generator.rb
|
|
268
268
|
- lib/generators/action_trace/install/templates/initializers/action_trace.rb.tt
|
|
269
269
|
- lib/generators/action_trace/install/templates/migrations/add_version_id_to_activities.rb.tt
|
|
270
|
-
- lib/generators/action_trace/views/templates/views/action_trace/activity_logs/_index.html.erb
|
|
271
|
-
- lib/generators/action_trace/views/templates/views/action_trace/activity_logs/index.html.erb
|
|
272
270
|
- lib/generators/action_trace/views/views_generator.rb
|
|
273
271
|
- lib/tasks/action_trace_tasks.rake
|
|
274
272
|
homepage: https://github.com/Engim-eu/action_trace
|
data/lib/generators/action_trace/views/templates/views/action_trace/activity_logs/index.html.erb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= render partial: 'index' %>
|