lesli_audit 1.1.1 → 1.1.3

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +6 -1
  3. data/app/assets/stylesheets/lesli_audit/application.css +549 -35
  4. data/app/controllers/lesli_audit/accounts_controller.rb +7 -3
  5. data/app/controllers/lesli_audit/analytics_controller.rb +16 -0
  6. data/app/controllers/lesli_audit/logs_controller.rb +12 -7
  7. data/app/controllers/lesli_audit/traffic_controller.rb +25 -0
  8. data/app/controllers/lesli_audit/users_controller.rb +7 -4
  9. data/app/interfaces/lesli_audit/logger_interface.rb +56 -58
  10. data/app/jobs/lesli_audit/cloudflare_traffic_sync_job.rb +78 -0
  11. data/app/jobs/lesli_audit/retention_cleanup_job.rb +9 -0
  12. data/app/models/concerns/lesli_audit/append_only.rb +12 -0
  13. data/app/models/lesli_audit/account.rb +38 -10
  14. data/app/models/lesli_audit/account_device.rb +3 -1
  15. data/app/models/lesli_audit/account_log.rb +12 -7
  16. data/app/models/lesli_audit/account_request.rb +3 -1
  17. data/app/models/lesli_audit/cloudflare_traffic_sync.rb +99 -0
  18. data/app/models/lesli_audit/traffic_breakdown.rb +38 -0
  19. data/app/models/lesli_audit/traffic_rollup.rb +33 -0
  20. data/app/models/lesli_audit/user_journal.rb +14 -3
  21. data/app/models/lesli_audit/user_log.rb +12 -3
  22. data/app/models/lesli_audit/user_request.rb +7 -3
  23. data/app/services/lesli_audit/activity_audit.rb +134 -0
  24. data/app/services/lesli_audit/analytics_service.rb +237 -0
  25. data/app/services/lesli_audit/cloudflare/configuration.rb +92 -0
  26. data/app/services/lesli_audit/cloudflare/graphql_client.rb +309 -0
  27. data/app/services/lesli_audit/cloudflare/snapshot_converter.rb +101 -0
  28. data/app/services/lesli_audit/cloudflare/sync_service.rb +79 -0
  29. data/app/services/lesli_audit/cloudflare_traffic_snapshot.rb +182 -0
  30. data/app/services/lesli_audit/log_service.rb +99 -5
  31. data/app/services/lesli_audit/request_service.rb +74 -44
  32. data/app/services/lesli_audit/retention_cleanup.rb +146 -0
  33. data/app/services/lesli_audit/traffic_service.rb +216 -0
  34. data/app/services/lesli_audit/traffic_snapshot_importer.rb +120 -0
  35. data/app/services/lesli_audit/user_agent_parser.rb +51 -0
  36. data/app/services/lesli_audit/user_service.rb +119 -150
  37. data/app/views/lesli_audit/{visitors → analytics}/index.html.erb +40 -30
  38. data/app/views/lesli_audit/logs/index.html.erb +88 -19
  39. data/app/views/lesli_audit/logs/show.html.erb +41 -7
  40. data/app/views/lesli_audit/partials/_navigation.html.erb +5 -4
  41. data/app/views/lesli_audit/requests/index.html.erb +80 -19
  42. data/app/views/lesli_audit/traffic/_breakdown.html.erb +46 -0
  43. data/app/views/lesli_audit/traffic/index.html.erb +177 -0
  44. data/app/views/lesli_audit/users/index.html.erb +97 -43
  45. data/config/locales/translations.en.yml +137 -1
  46. data/config/locales/translations.es.yml +137 -1
  47. data/config/locales/translations.fr.yml +132 -1
  48. data/config/locales/translations.it.yml +132 -1
  49. data/config/locales/translations.pt.yml +132 -1
  50. data/config/routes.rb +6 -22
  51. data/db/migrate/v1.0/0501000110_create_lesli_audit_accounts.rb +14 -1
  52. data/db/migrate/v1.0/0501110110_create_lesli_audit_account_logs.rb +11 -6
  53. data/db/migrate/v1.0/0501110210_create_lesli_audit_account_devices.rb +10 -7
  54. data/db/migrate/v1.0/0501110310_create_lesli_audit_account_requests.rb +10 -7
  55. data/db/migrate/v1.0/0501120110_create_lesli_audit_user_logs.rb +12 -7
  56. data/db/migrate/v1.0/0501120210_create_lesli_audit_user_journals.rb +16 -8
  57. data/db/migrate/v1.0/0501120310_create_lesli_audit_user_requests.rb +13 -10
  58. data/db/migrate/v1.0/0501130110_create_lesli_audit_traffic_rollups.rb +55 -0
  59. data/db/migrate/v1.0/0501130210_create_lesli_audit_traffic_breakdowns.rb +41 -0
  60. data/db/migrate/v1.0/0501130310_create_lesli_audit_cloudflare_traffic_syncs.rb +42 -0
  61. data/db/seed/devices.rb +3 -2
  62. data/db/seed/requests.rb +3 -3
  63. data/db/seed/traffic.rb +128 -0
  64. data/db/seed/users.rb +68 -27
  65. data/db/seeds.rb +3 -2
  66. data/lib/lesli_audit/engine.rb +1 -12
  67. data/lib/lesli_audit/version.rb +2 -2
  68. data/lib/tasks/lesli_audit_cloudflare_traffic.rake +16 -0
  69. data/lib/tasks/lesli_audit_tasks.rake +12 -4
  70. data/readme.md +28 -5
  71. metadata +36 -9
  72. data/app/assets/stylesheets/lesli_audit/application.tailwind.css +0 -2
  73. data/app/controllers/lesli_audit/visitors_controller.rb +0 -14
  74. data/app/models/concerns/lesli_audit/user_associations.rb +0 -11
  75. data/app/services/lesli_audit/visitor_service.rb +0 -239
@@ -0,0 +1,42 @@
1
+ class CreateLesliAuditCloudflareTrafficSyncs < ActiveRecord::Migration[8.1]
2
+ def change
3
+ create_table :lesli_audit_cloudflare_traffic_syncs do |t|
4
+ t.references :account,
5
+ null: false,
6
+ foreign_key: { to_table: :lesli_audit_accounts, on_delete: :cascade }
7
+ t.string :zone_id, null: false
8
+ t.date :period_start, null: false
9
+ t.date :period_end, null: false
10
+ t.string :status, null: false, default: "pending"
11
+ t.string :execution_id
12
+ t.integer :snapshots_count, null: false, default: 0
13
+ t.datetime :started_at
14
+ t.datetime :finished_at
15
+ t.datetime :last_synced_at
16
+ t.text :error_message
17
+ t.timestamps null: false
18
+ end
19
+
20
+ add_index(
21
+ :lesli_audit_cloudflare_traffic_syncs,
22
+ %i[account_id zone_id period_start period_end],
23
+ unique: true,
24
+ name: "index_lesli_audit_cloudflare_syncs_on_account_zone_and_period"
25
+ )
26
+ add_check_constraint(
27
+ :lesli_audit_cloudflare_traffic_syncs,
28
+ "period_start <= period_end",
29
+ name: "lesli_audit_cloudflare_syncs_valid_period"
30
+ )
31
+ add_check_constraint(
32
+ :lesli_audit_cloudflare_traffic_syncs,
33
+ "snapshots_count >= 0",
34
+ name: "lesli_audit_cloudflare_syncs_snapshots_count_nonnegative"
35
+ )
36
+ add_check_constraint(
37
+ :lesli_audit_cloudflare_traffic_syncs,
38
+ "status IN ('pending', 'running', 'succeeded', 'failed')",
39
+ name: "lesli_audit_cloudflare_syncs_valid_status"
40
+ )
41
+ end
42
+ end
data/db/seed/devices.rb CHANGED
@@ -45,7 +45,8 @@ current_user = Lesli::User.first
45
45
  # controllers to seed
46
46
  [
47
47
  "Mac",
48
- "Windows"
48
+ "Windows",
49
+ "Linux"
49
50
  ].each do |platform|
50
51
 
51
52
  [
@@ -68,7 +69,7 @@ current_user = Lesli::User.first
68
69
  :agent_platform => platform,
69
70
  :agent_browser => browser,
70
71
  :agent_device => device,
71
- :created_at => date,
72
+ :date => date,
72
73
  )
73
74
  end
74
75
  end
data/db/seed/requests.rb CHANGED
@@ -58,7 +58,7 @@ session = current_user.sessions.first
58
58
  ).find_or_create_by(
59
59
  :request_controller => controller,
60
60
  :request_action => "show",
61
- :created_at => date,
61
+ :date => date,
62
62
  )
63
63
 
64
64
  current_user.account.audit.user_requests.create_with(
@@ -66,8 +66,8 @@ session = current_user.sessions.first
66
66
  ).find_or_create_by(
67
67
  :request_controller => controller,
68
68
  :request_action => "show",
69
- :created_at => date,
70
- :session => session,
69
+ :date => date,
70
+ :session_id => session&.id,
71
71
  :user => current_user
72
72
  )
73
73
  end
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ core_account = Lesli::Account.first
4
+ return unless core_account
5
+
6
+ audit_account = core_account.audit || LesliAudit::Account.create!(
7
+ account: core_account,
8
+ name: core_account.name
9
+ )
10
+
11
+ resources = [ {
12
+ resource_type: "Profile",
13
+ resource_id: 1_001,
14
+ path: "/demo/sofia",
15
+ baseline: 92
16
+ }, {
17
+ resource_type: "Profile",
18
+ resource_id: 1_002,
19
+ path: "/demo/mateo",
20
+ baseline: 78
21
+ }, {
22
+ resource_type: "Profile",
23
+ resource_id: 1_003,
24
+ path: "/demo/valentina",
25
+ baseline: 72
26
+ }, {
27
+ resource_type: "Profile",
28
+ resource_id: 1_004,
29
+ path: "/demo/santiago",
30
+ baseline: 68
31
+ }, {
32
+ resource_type: "Business",
33
+ resource_id: 2_001,
34
+ path: "/demo/cafe",
35
+ baseline: 64
36
+ }, {
37
+ resource_type: "Business",
38
+ resource_id: 2_002,
39
+ path: "/demo/studio",
40
+ baseline: 56
41
+ }, {
42
+ resource_type: "Business",
43
+ resource_id: 2_003,
44
+ path: "/demo/bakery",
45
+ baseline: 52
46
+ }, {
47
+ resource_type: "Event",
48
+ resource_id: 3_001,
49
+ path: "/demo/festival",
50
+ baseline: 38
51
+ }, {
52
+ resource_type: "Event",
53
+ resource_id: 3_002,
54
+ path: "/demo/conference",
55
+ baseline: 44
56
+ }, {
57
+ resource_type: "Event",
58
+ resource_id: 3_003,
59
+ path: "/demo/workshop",
60
+ baseline: 34
61
+ } ].freeze
62
+
63
+ split = lambda do |total, weights|
64
+ remaining = total
65
+ weights.each_with_index.map do |weight, index|
66
+ value = index == weights.length - 1 ? remaining : (total * weight).round
67
+ remaining -= value
68
+ value
69
+ end
70
+ end
71
+
72
+ resources.each_with_index do |resource, resource_index|
73
+ (29.days.ago.to_date..Date.current).each_with_index do |date, day_index|
74
+ weekday_lift = date.on_weekend? ? 8 : 18
75
+ trend = day_index * (resource_index + 1)
76
+ page_views = resource[:baseline] + weekday_lift + trend
77
+ visits = (page_views * 0.72).round
78
+
79
+ country_views = split.call(page_views, [ 0.72, 0.18, 0.10 ])
80
+ country_visits = split.call(visits, [ 0.72, 0.18, 0.10 ])
81
+ device_views = split.call(page_views, [ 0.68, 0.27, 0.05 ])
82
+ device_visits = split.call(visits, [ 0.68, 0.27, 0.05 ])
83
+ referrer_views = split.call(page_views, [ 0.42, 0.31, 0.17, 0.10 ])
84
+ referrer_visits = split.call(visits, [ 0.42, 0.31, 0.17, 0.10 ])
85
+
86
+ breakdowns = []
87
+ %w[GT US MX].each_with_index do |value, index|
88
+ breakdowns << {
89
+ dimension: "country",
90
+ value:,
91
+ page_views: country_views[index],
92
+ visits: country_visits[index]
93
+ }
94
+ end
95
+ %w[mobile desktop tablet].each_with_index do |value, index|
96
+ breakdowns << {
97
+ dimension: "device",
98
+ value:,
99
+ page_views: device_views[index],
100
+ visits: device_visits[index]
101
+ }
102
+ end
103
+ %w[direct instagram google facebook].each_with_index do |value, index|
104
+ breakdowns << {
105
+ dimension: "referrer",
106
+ value:,
107
+ page_views: referrer_views[index],
108
+ visits: referrer_visits[index]
109
+ }
110
+ end
111
+
112
+ snapshot = LesliAudit::CloudflareTrafficSnapshot.new(
113
+ hostname: "demo.lesli.dev",
114
+ path: resource[:path],
115
+ resource_type: resource[:resource_type],
116
+ resource_id: resource[:resource_id],
117
+ date:,
118
+ page_views:,
119
+ visits:,
120
+ snapshot_at: date.in_time_zone.end_of_day,
121
+ breakdowns:
122
+ )
123
+ LesliAudit::TrafficSnapshotImporter.call(
124
+ account: audit_account,
125
+ snapshot:
126
+ )
127
+ end
128
+ end
data/db/seed/users.rb CHANGED
@@ -1,31 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- return unless Rails.env.development?
4
-
5
3
  account = Lesli::Account.first!
4
+ audit_account = account.audit || LesliAudit::Account.create!(
5
+ account:,
6
+ name: account.name
7
+ )
6
8
 
7
- password = if defined?(Devise)
9
+ password = if defined?(Devise::Encryptor)
8
10
  Devise::Encryptor.digest(Lesli::User, "password123")
9
11
  else
10
- BCrypt::Password.create("password123")
12
+ ""
11
13
  end
12
14
 
13
15
  now = Time.current
14
16
 
15
- # Adjust these numbers freely while building the dashboard.
16
- TOTAL_USERS = 1_000
17
- TOTAL_INACTIVE_USERS = 120
18
- TOTAL_LOCKED_USERS = 45
19
- TOTAL_UNCONFIRMED_USERS = 80
20
- TOTAL_USERS_NEVER_SIGNED_IN = 140
21
- TOTAL_USERS_ACTIVE_LAST_30_DAYS = 520
22
- TOTAL_NEW_USERS_LAST_30_DAYS = 75
23
- TOTAL_USERS_WITH_FAILED_ATTEMPTS = 60
24
- TOTAL_DELETED_USERS = 25
17
+ totals = {
18
+ users: 100,
19
+ inactive: 12,
20
+ locked: 5,
21
+ unconfirmed: 8,
22
+ never_signed_in: 14,
23
+ active_last_30_days: 52,
24
+ new_last_30_days: 10,
25
+ failed_attempts: 6,
26
+ deleted: 3
27
+ }.freeze
25
28
 
26
29
  users = []
27
30
 
28
- TOTAL_USERS.times do |index|
31
+ totals.fetch(:users).times do |index|
29
32
  uid = "DEV-USR-#{index.to_s.rjust(5, "0")}"
30
33
 
31
34
  users << {
@@ -55,32 +58,32 @@ TOTAL_USERS.times do |index|
55
58
  locked_until: nil,
56
59
  unlock_token: nil,
57
60
 
58
- created_at: now - rand(31..365).days,
61
+ created_at: now - (index % 330).days,
59
62
  updated_at: now,
60
63
  deleted_at: nil
61
64
  }
62
65
  end
63
66
 
64
67
  # Inactive users
65
- users.first(TOTAL_INACTIVE_USERS).each do |user|
68
+ users.first(totals.fetch(:inactive)).each do |user|
66
69
  user[:active] = false
67
70
  end
68
71
 
69
72
  # Locked users
70
- users.slice(120, TOTAL_LOCKED_USERS).each do |user|
73
+ users.slice(12, totals.fetch(:locked)).each do |user|
71
74
  user[:locked_at] = now - rand(1..15).days
72
75
  user[:locked_until] = now + rand(1..15).days
73
76
  end
74
77
 
75
78
  # Unconfirmed users
76
- users.slice(200, TOTAL_UNCONFIRMED_USERS).each do |user|
79
+ users.slice(20, totals.fetch(:unconfirmed)).each do |user|
77
80
  user[:confirmed_at] = nil
78
81
  user[:confirmation_sent_at] = now - rand(1..10).days
79
82
  user[:confirmation_token] = SecureRandom.hex(16)
80
83
  end
81
84
 
82
85
  # Never signed in
83
- users.slice(300, TOTAL_USERS_NEVER_SIGNED_IN).each do |user|
86
+ users.slice(30, totals.fetch(:never_signed_in)).each do |user|
84
87
  user[:sign_in_count] = 0
85
88
  user[:current_sign_in_at] = nil
86
89
  user[:last_sign_in_at] = nil
@@ -89,29 +92,67 @@ users.slice(300, TOTAL_USERS_NEVER_SIGNED_IN).each do |user|
89
92
  end
90
93
 
91
94
  # Active in the last 30 days
92
- users.slice(450, TOTAL_USERS_ACTIVE_LAST_30_DAYS).each do |user|
95
+ users.slice(45, totals.fetch(:active_last_30_days)).each do |user|
93
96
  user[:sign_in_count] = rand(1..100)
94
97
  user[:last_sign_in_at] = now - rand(0..29).days
95
98
  user[:current_sign_in_at] = user[:last_sign_in_at]
96
99
  end
97
100
 
98
101
  # New users in the last 30 days
99
- users.last(TOTAL_NEW_USERS_LAST_30_DAYS).each do |user|
102
+ users.last(totals.fetch(:new_last_30_days)).each do |user|
100
103
  user[:created_at] = now - rand(0..29).days
101
104
  user[:updated_at] = now
102
105
  end
103
106
 
104
107
  # Users with failed attempts
105
- users.slice(700, TOTAL_USERS_WITH_FAILED_ATTEMPTS).each do |user|
108
+ users.slice(70, totals.fetch(:failed_attempts)).each do |user|
106
109
  user[:failed_attempts] = rand(1..5)
107
110
  end
108
111
 
109
112
  # Soft-deleted users
110
- users.last(TOTAL_DELETED_USERS).each do |user|
113
+ users.last(totals.fetch(:deleted)).each do |user|
111
114
  user[:deleted_at] = now - rand(1..30).days
112
115
  end
113
116
 
114
- # Remove previous generated users only
115
- Lesli::User.where("uid LIKE ?", "DEV-USR-%").delete_all
117
+ # Remove only records owned by this seed so running it again is safe.
118
+ audit_account.user_journals.where("event_uid LIKE ?", "DEV-USR-ACTIVITY-%").delete_all
119
+ Lesli::User.unscoped.where("uid LIKE ?", "DEV-USR-%").delete_all!
120
+
121
+ # `unscoped` is required so acts_as_paranoid does not replace the explicit
122
+ # `deleted_at` values used to demonstrate deleted-user totals.
123
+ Lesli::User.unscoped.insert_all!(users)
124
+
125
+ # Retained journals provide realistic first/last activity for the Users report.
126
+ # They do not create request aggregates; the Requests report has its own seed.
127
+ demo_users = Lesli::User.where("uid LIKE ?", "DEV-USR-%").order(:id).limit(20)
128
+ journals = demo_users.flat_map do |user|
129
+ (13.days.ago.to_date..Date.current).flat_map do |date|
130
+ first_activity = date.in_time_zone + 8.hours + (user.id % 45).minutes
131
+ last_activity = first_activity + 8.hours + (user.id % 90).minutes
132
+ event_prefix = "DEV-USR-ACTIVITY-#{user.uid}-#{date.iso8601}"
133
+
134
+ [ {
135
+ account_id: audit_account.id,
136
+ user_id: user.id,
137
+ event_uid: "#{event_prefix}-FIRST",
138
+ request_controller: "lesli_audit/users",
139
+ request_action: "index",
140
+ date:,
141
+ retain: true,
142
+ created_at: first_activity,
143
+ updated_at: first_activity
144
+ }, {
145
+ account_id: audit_account.id,
146
+ user_id: user.id,
147
+ event_uid: "#{event_prefix}-LAST",
148
+ request_controller: "lesli_audit/users",
149
+ request_action: "index",
150
+ date:,
151
+ retain: true,
152
+ created_at: last_activity,
153
+ updated_at: last_activity
154
+ } ]
155
+ end
156
+ end
116
157
 
117
- Lesli::User.insert_all!(users)
158
+ LesliAudit::UserJournal.insert_all!(journals)
data/db/seeds.rb CHANGED
@@ -27,15 +27,16 @@ Building a better future, one line of code at a time.
27
27
  @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
28
 
29
29
  // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
30
+ // ·
31
31
  =end
32
32
 
33
33
  Termline.info("Loading seeds for: LesliAudit #{LesliAudit::VERSION} (#{LesliAudit::BUILD})")
34
34
 
35
35
 
36
36
  # · load specific environment seeds
37
- if Rails.env.development? || Lesli.config.demo
37
+ if Rails.env.development? || Lesli.config.demo
38
38
  load LesliAudit::Engine.root.join("db", "seed", "requests.rb")
39
39
  load LesliAudit::Engine.root.join("db", "seed", "devices.rb")
40
+ load LesliAudit::Engine.root.join("db", "seed", "traffic.rb")
40
41
  load LesliAudit::Engine.root.join("db", "seed", "users.rb")
41
42
  end
@@ -1,18 +1,7 @@
1
- require "useragent"
2
1
  module LesliAudit
3
2
  class Engine < ::Rails::Engine
4
3
  isolate_namespace LesliAudit
5
-
6
- config.to_prepare do
7
- unless Lesli::User < LesliAudit::UserAssociations
8
- Lesli::User.include(LesliAudit::UserAssociations)
9
- end
10
- end
11
-
12
- initializer :lesli_admin do |app|
13
-
14
- # register assets manifest
15
- config.assets.precompile += %w[lesli_audit_manifest.js]
4
+ initializer :lesli_audit do |app|
16
5
 
17
6
  app.config.assets.paths << root.join("app", "javascript").to_s
18
7
 
@@ -1,4 +1,4 @@
1
1
  module LesliAudit
2
- VERSION = "1.1.1"
3
- BUILD = "1791607001"
2
+ VERSION = "1.1.3"
3
+ BUILD = "1793282397"
4
4
  end
@@ -0,0 +1,16 @@
1
+ namespace :cloudflare_traffic do
2
+ desc "Enqueue recent Cloudflare traffic for every configured account"
3
+ task sync: :environment do
4
+ LesliAudit::CloudflareTrafficSyncJob.enqueue_recent
5
+ end
6
+
7
+ desc "Enqueue the initial Cloudflare traffic backfill"
8
+ task :backfill, %i[account_id days] => :environment do |_task, arguments|
9
+ account_ids = arguments[:account_id].presence ||
10
+ LesliAudit::Cloudflare::Configuration.from_application.account_ids
11
+
12
+ Array(account_ids).each do |account_id|
13
+ LesliAudit::CloudflareTrafficSyncJob.enqueue_backfill(account_id, days: arguments[:days])
14
+ end
15
+ end
16
+ end
@@ -1,4 +1,12 @@
1
- # desc "Explaining what the task does"
2
- # task :lesli_audit do
3
- # # Task goes here
4
- # end
1
+ namespace :lesli_audit do
2
+ namespace :retention do
3
+ desc "Delete expired LesliAudit data using the configured retention policy"
4
+ task cleanup: :environment do
5
+ deleted = LesliAudit::RetentionCleanup.call
6
+
7
+ deleted.each do |table, count|
8
+ puts "#{table}: #{count} deleted"
9
+ end
10
+ end
11
+ end
12
+ end
data/readme.md CHANGED
@@ -8,8 +8,8 @@
8
8
  <br />
9
9
 
10
10
  <div align="center">
11
- <a target="_blank" href="https://github.com/LesliTech/LesliAudit/actions/workflows/lesli-ci-tests.yaml">
12
- <img alt="LesliAudit test status" src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliAudit/lesli-ci-tests.yaml?branch=master&style=for-the-badge&logo=github&label=tests">
11
+ <a target="_blank" href="https://github.com/LesliTech/LesliAudit/actions/workflows/lesli-ci-engine.yaml">
12
+ <img alt="LesliAudit test status" src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliAudit/lesli-ci-engine.yaml?branch=master&style=for-the-badge&logo=github&label=tests">
13
13
  </a>
14
14
  <a target="_blank" href="https://rubygems.org/gems/lesli_audit">
15
15
  <img alt="Gem Version" src="https://img.shields.io/gem/v/lesli_audit?style=for-the-badge&logo=ruby">
@@ -47,10 +47,24 @@ It records account activity and provides administrators with searchable operatio
47
47
 
48
48
  - Account activity and audit logs
49
49
  - Request and navigation history
50
- - Visitor and authenticated-user analytics
51
- - Device and user-agent information
50
+ - Request, device, and authenticated-user analytics
51
+ - Cloudflare-imported traffic snapshots for resources served outside Rails
52
+ - Direct account and authenticated-user request counters
53
+ - Configurable batched data retention
54
+ - Normalized browser, platform, and device categories
52
55
  - Detailed views for investigating recorded activity
53
56
 
57
+ Activity logs are explicit append-only business or security events. They are
58
+ separate from request analytics: user requests are grouped counters, while
59
+ user journals are individual normalized HTTP request events.
60
+
61
+ The interface uses five single-word reports in a fixed order: **Users**,
62
+ **Analytics**, **Traffic**, **Requests**, and **Logs**. Analytics measures
63
+ authenticated application use. Traffic presents aggregate resource visits
64
+ imported from Cloudflare without logging individual requests. Cloudflare
65
+ `count` is presented as mapped-resource page views and `sum.visits` as visits;
66
+ neither metric is a unique person or audit evidence.
67
+
54
68
  <br />
55
69
 
56
70
  ## Try LesliAudit
@@ -64,7 +78,8 @@ It records account activity and provides administrators with searchable operatio
64
78
 
65
79
  ### Requirements
66
80
 
67
- - A Rails application with [Lesli](https://rubygems.org/gems/lesli)
81
+ - Ruby 3.x and Rails `~> 8.1`
82
+ - A Rails application with [Lesli](https://rubygems.org/gems/lesli) `~> 5.1.0`
68
83
  - SQLite by default, or PostgreSQL when preferred by the host application
69
84
 
70
85
  ### Install LesliAudit
@@ -143,6 +158,14 @@ bin/rails test
143
158
 
144
159
  - [Lesli website](https://www.lesli.dev/)
145
160
  - [Documentation](https://www.lesli.dev/engines/audit)
161
+ - [Architecture and data policy](./docs/about/architecture.md)
162
+ - [Configuration](./docs/about/configuration.md)
163
+ - [Request analytics](./docs/analytics/overview.md)
164
+ - [Provider traffic](./docs/traffic/overview.md)
165
+ - [Cloudflare Traffic integration](./docs/traffic/cloudflare.md)
166
+ - [Activity events](./docs/events/overview.md)
167
+ - [Operational tasks](./docs/about/tasks.md)
168
+ - [Database](./docs/about/database.md)
146
169
  - [Frontend development](./docs/about/frontend.md)
147
170
  - [Release notes](https://github.com/LesliTech/LesliAudit/releases)
148
171
  - [Issue tracker](https://github.com/LesliTech/LesliAudit/issues)
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_audit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-11-16 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: lesli
@@ -48,14 +49,14 @@ files:
48
49
  - app/assets/images/lesli_audit/audit-logo.svg
49
50
  - app/assets/javascripts/lesli_audit/application.js
50
51
  - app/assets/stylesheets/lesli_audit/application.css
51
- - app/assets/stylesheets/lesli_audit/application.tailwind.css
52
52
  - app/controllers/lesli_audit/accounts_controller.rb
53
+ - app/controllers/lesli_audit/analytics_controller.rb
53
54
  - app/controllers/lesli_audit/application_controller.rb
54
55
  - app/controllers/lesli_audit/dashboards_controller.rb
55
56
  - app/controllers/lesli_audit/logs_controller.rb
56
57
  - app/controllers/lesli_audit/requests_controller.rb
58
+ - app/controllers/lesli_audit/traffic_controller.rb
57
59
  - app/controllers/lesli_audit/users_controller.rb
58
- - app/controllers/lesli_audit/visitors_controller.rb
59
60
  - app/helpers/lesli_audit/accounts_helper.rb
60
61
  - app/helpers/lesli_audit/application_helper.rb
61
62
  - app/helpers/lesli_audit/dashboards_helper.rb
@@ -65,21 +66,37 @@ files:
65
66
  - app/helpers/lesli_audit/users_helper.rb
66
67
  - app/interfaces/lesli_audit/logger_interface.rb
67
68
  - app/jobs/lesli_audit/application_job.rb
69
+ - app/jobs/lesli_audit/cloudflare_traffic_sync_job.rb
70
+ - app/jobs/lesli_audit/retention_cleanup_job.rb
68
71
  - app/mailers/lesli_audit/application_mailer.rb
69
- - app/models/concerns/lesli_audit/user_associations.rb
72
+ - app/models/concerns/lesli_audit/append_only.rb
70
73
  - app/models/lesli_audit/account.rb
71
74
  - app/models/lesli_audit/account_device.rb
72
75
  - app/models/lesli_audit/account_log.rb
73
76
  - app/models/lesli_audit/account_request.rb
74
77
  - app/models/lesli_audit/application_record.rb
78
+ - app/models/lesli_audit/cloudflare_traffic_sync.rb
75
79
  - app/models/lesli_audit/dashboard.rb
80
+ - app/models/lesli_audit/traffic_breakdown.rb
81
+ - app/models/lesli_audit/traffic_rollup.rb
76
82
  - app/models/lesli_audit/user_journal.rb
77
83
  - app/models/lesli_audit/user_log.rb
78
84
  - app/models/lesli_audit/user_request.rb
85
+ - app/services/lesli_audit/activity_audit.rb
86
+ - app/services/lesli_audit/analytics_service.rb
87
+ - app/services/lesli_audit/cloudflare/configuration.rb
88
+ - app/services/lesli_audit/cloudflare/graphql_client.rb
89
+ - app/services/lesli_audit/cloudflare/snapshot_converter.rb
90
+ - app/services/lesli_audit/cloudflare/sync_service.rb
91
+ - app/services/lesli_audit/cloudflare_traffic_snapshot.rb
79
92
  - app/services/lesli_audit/log_service.rb
80
93
  - app/services/lesli_audit/request_service.rb
94
+ - app/services/lesli_audit/retention_cleanup.rb
95
+ - app/services/lesli_audit/traffic_service.rb
96
+ - app/services/lesli_audit/traffic_snapshot_importer.rb
97
+ - app/services/lesli_audit/user_agent_parser.rb
81
98
  - app/services/lesli_audit/user_service.rb
82
- - app/services/lesli_audit/visitor_service.rb
99
+ - app/views/lesli_audit/analytics/index.html.erb
83
100
  - app/views/lesli_audit/dashboards/_component-calendar.html.erb
84
101
  - app/views/lesli_audit/dashboards/edit.html.erb
85
102
  - app/views/lesli_audit/dashboards/index.html.erb
@@ -89,8 +106,9 @@ files:
89
106
  - app/views/lesli_audit/logs/show.html.erb
90
107
  - app/views/lesli_audit/partials/_navigation.html.erb
91
108
  - app/views/lesli_audit/requests/index.html.erb
109
+ - app/views/lesli_audit/traffic/_breakdown.html.erb
110
+ - app/views/lesli_audit/traffic/index.html.erb
92
111
  - app/views/lesli_audit/users/index.html.erb
93
- - app/views/lesli_audit/visitors/index.html.erb
94
112
  - config/locales/translations.en.yml
95
113
  - config/locales/translations.es.yml
96
114
  - config/locales/translations.fr.yml
@@ -104,14 +122,19 @@ files:
104
122
  - db/migrate/v1.0/0501120110_create_lesli_audit_user_logs.rb
105
123
  - db/migrate/v1.0/0501120210_create_lesli_audit_user_journals.rb
106
124
  - db/migrate/v1.0/0501120310_create_lesli_audit_user_requests.rb
125
+ - db/migrate/v1.0/0501130110_create_lesli_audit_traffic_rollups.rb
126
+ - db/migrate/v1.0/0501130210_create_lesli_audit_traffic_breakdowns.rb
127
+ - db/migrate/v1.0/0501130310_create_lesli_audit_cloudflare_traffic_syncs.rb
107
128
  - db/seed/devices.rb
108
129
  - db/seed/requests.rb
130
+ - db/seed/traffic.rb
109
131
  - db/seed/users.rb
110
132
  - db/seeds.rb
111
133
  - db/version_structure.rb
112
134
  - lib/lesli_audit.rb
113
135
  - lib/lesli_audit/engine.rb
114
136
  - lib/lesli_audit/version.rb
137
+ - lib/tasks/lesli_audit_cloudflare_traffic.rake
115
138
  - lib/tasks/lesli_audit_tasks.rake
116
139
  - license
117
140
  - readme.md
@@ -120,8 +143,11 @@ licenses:
120
143
  - GPL-3.0
121
144
  metadata:
122
145
  homepage_uri: https://www.lesli.dev/
123
- changelog_uri: https://github.com/LesliTech/LesliAudit
146
+ changelog_uri: https://github.com/LesliTech/LesliAudit/releases
124
147
  source_code_uri: https://github.com/LesliTech/LesliAudit
148
+ bug_tracker_uri: https://github.com/LesliTech/LesliAudit/issues
149
+ documentation_uri: https://www.lesli.dev/engines/audit/
150
+ post_install_message:
125
151
  rdoc_options: []
126
152
  require_paths:
127
153
  - lib
@@ -136,7 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
162
  - !ruby/object:Gem::Version
137
163
  version: '0'
138
164
  requirements: []
139
- rubygems_version: 3.7.1
165
+ rubygems_version: 3.5.16
166
+ signing_key:
140
167
  specification_version: 4
141
168
  summary: Logs Activities & Analytics for The Lesli Framework
142
169
  test_files: []
@@ -1,2 +0,0 @@
1
- /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
- @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--color-amber-600:oklch(66.6% .179 58.318);--color-sky-600:oklch(58.8% .158 241.966);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-500:oklch(55.4% .046 257.417);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-900:oklch(20.8% .042 265.755);--color-white:#fff;--spacing:.25rem;--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--radius-2xl:1rem}}@layer utilities{.absolute{position:absolute}.relative{position:relative}.inset-y-0{inset-block:0}.left-0{left:0}.isolate{isolation:isolate}.-z-10{z-index:calc(10 * -1)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-6{margin-top:calc(var(--spacing) * 6)}.flex{display:flex}.grid{display:grid}.inline-flex{display:inline-flex}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-full{width:100%}.\!min-w-0{min-width:0!important}.min-w-0{min-width:0}.shrink-0{flex-shrink:0}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.rounded-2xl{border-radius:var(--radius-2xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-slate-200{border-color:var(--color-slate-200)}.bg-slate-100{background-color:var(--color-slate-100)}.bg-white{background-color:var(--color-white)}.\!p-0{padding:0!important}.p-5{padding:calc(var(--spacing) * 5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.pb-8{padding-bottom:calc(var(--spacing) * 8)}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.leading-none{--tw-leading:1;line-height:1}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.text-amber-600{color:var(--color-amber-600)}.text-rose-600{color:var(--color-rose-600)}.text-sky-600{color:var(--color-sky-600)}.text-slate-500{color:var(--color-slate-500)}.text-slate-700{color:var(--color-slate-700)}.text-slate-900{color:var(--color-slate-900)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}@media (min-width:40rem){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:64rem){.lg\:w-2\/5{width:40%}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}