bug_reports_client 0.1.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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +14 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +281 -0
  5. data/app/assets/tailwind/bug_reports_client/engine.css +7 -0
  6. data/app/controllers/bug_reports_client/application_controller.rb +35 -0
  7. data/app/controllers/bug_reports_client/bug_reports_controller.rb +308 -0
  8. data/app/controllers/bug_reports_client/webhooks_controller.rb +94 -0
  9. data/app/helpers/bug_reports_client/bug_reports_helper.rb +61 -0
  10. data/app/javascript/bug_reports_client/controllers/error_summary_controller.js +14 -0
  11. data/app/javascript/bug_reports_client/controllers/file_limit_controller.js +31 -0
  12. data/app/javascript/bug_reports_client/controllers/report_type_controller.js +54 -0
  13. data/app/javascript/bug_reports_client/controllers/screenshot_dropzone_controller.js +151 -0
  14. data/app/jobs/bug_reports_client/report_error_job.rb +44 -0
  15. data/app/models/bug_reports_client/application_record.rb +5 -0
  16. data/app/models/bug_reports_client/bug_report.rb +74 -0
  17. data/app/models/bug_reports_client/error_event.rb +46 -0
  18. data/app/models/concerns/bug_reports_client/reporter.rb +15 -0
  19. data/app/services/bug_reports_client/api_client.rb +174 -0
  20. data/app/services/bug_reports_client/description_builder.rb +91 -0
  21. data/app/views/bug_reports_client/bug_reports/_field_checkbox.html.erb +18 -0
  22. data/app/views/bug_reports_client/bug_reports/_field_select.html.erb +15 -0
  23. data/app/views/bug_reports_client/bug_reports/_field_text.html.erb +13 -0
  24. data/app/views/bug_reports_client/bug_reports/_field_textarea.html.erb +13 -0
  25. data/app/views/bug_reports_client/bug_reports/_filters.html.erb +31 -0
  26. data/app/views/bug_reports_client/bug_reports/_form.html.erb +185 -0
  27. data/app/views/bug_reports_client/bug_reports/_pagination.html.erb +21 -0
  28. data/app/views/bug_reports_client/bug_reports/_rating_badge.html.erb +11 -0
  29. data/app/views/bug_reports_client/bug_reports/_related_error.html.erb +20 -0
  30. data/app/views/bug_reports_client/bug_reports/_status_badge.html.erb +12 -0
  31. data/app/views/bug_reports_client/bug_reports/_type_badge.html.erb +6 -0
  32. data/app/views/bug_reports_client/bug_reports/all.html.erb +66 -0
  33. data/app/views/bug_reports_client/bug_reports/edit.html.erb +40 -0
  34. data/app/views/bug_reports_client/bug_reports/index.html.erb +104 -0
  35. data/app/views/bug_reports_client/bug_reports/new.html.erb +33 -0
  36. data/app/views/bug_reports_client/shared/_after_dismiss.turbo_stream.erb +4 -0
  37. data/app/views/bug_reports_client/shared/_alerts.html.erb +22 -0
  38. data/config/form_schema.yml +114 -0
  39. data/config/importmap.rb +6 -0
  40. data/config/locales/en.yml +213 -0
  41. data/config/routes.rb +14 -0
  42. data/db/migrate/20260721000001_create_bug_reports.rb +32 -0
  43. data/db/migrate/20260723000002_create_bug_report_error_events.rb +20 -0
  44. data/db/migrate/20260723000003_add_activity_to_bug_report_error_events.rb +10 -0
  45. data/lib/bug_reports_client/configuration.rb +121 -0
  46. data/lib/bug_reports_client/engine.rb +49 -0
  47. data/lib/bug_reports_client/error_context.rb +31 -0
  48. data/lib/bug_reports_client/error_reporter.rb +116 -0
  49. data/lib/bug_reports_client/form_schema.rb +204 -0
  50. data/lib/bug_reports_client/main_app_routes.rb +68 -0
  51. data/lib/bug_reports_client/version.rb +3 -0
  52. data/lib/bug_reports_client.rb +39 -0
  53. data/lib/generators/bug_reports_client/install/install_generator.rb +39 -0
  54. data/lib/generators/bug_reports_client/install/templates/AFTER_INSTALL +28 -0
  55. data/lib/generators/bug_reports_client/install/templates/bug_report_issue.md.example +23 -0
  56. data/lib/generators/bug_reports_client/install/templates/initializer.rb +31 -0
  57. data/lib/generators/bug_reports_client/views/views_generator.rb +19 -0
  58. metadata +134 -0
@@ -0,0 +1,39 @@
1
+ require "rails/generators"
2
+
3
+ module BugReportsClient
4
+ module Generators
5
+ # Sets a host app up to use the engine:
6
+ # bin/rails g bug_reports_client:install
7
+ #
8
+ # Creates the initializer, mounts the engine, copies the default form
9
+ # schema (ready to customise) and an example issue template, then prints
10
+ # the remaining manual checklist.
11
+ class InstallGenerator < Rails::Generators::Base
12
+ source_root File.expand_path("templates", __dir__)
13
+
14
+ def create_initializer
15
+ template "initializer.rb", "config/initializers/bug_reports_client.rb"
16
+ end
17
+
18
+ def mount_engine
19
+ route 'mount BugReportsClient::Engine => "/bug_reports"'
20
+ end
21
+
22
+ # The copied schema is identical to the engine default - editing it (or
23
+ # deleting it to fall back to the default) is the customisation point.
24
+ def copy_form_schema
25
+ copy_file BugReportsClient::Engine.root.join("config/form_schema.yml"), "config/bug_report_form.yml"
26
+ end
27
+
28
+ # Copied with an .example suffix because the presence of
29
+ # config/bug_report_issue.md switches issue rendering to template mode.
30
+ def copy_issue_template_example
31
+ copy_file "bug_report_issue.md.example", "config/bug_report_issue.md.example"
32
+ end
33
+
34
+ def print_checklist
35
+ readme "AFTER_INSTALL" if behavior == :invoke
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+
2
+ ===============================================================================
3
+ bug_reports_client installed. Remaining steps:
4
+
5
+ 1. Migrations:
6
+ bin/rails bug_reports_client:install:migrations && bin/rails db:migrate
7
+
8
+ 2. Link your user model (app/models/user.rb):
9
+ include BugReportsClient::Reporter
10
+
11
+ 3. Add a menu link and the resolved-report alerts to your layout:
12
+ <%= link_to "Report a bug", bug_reports_client.new_bug_report_path %>
13
+ <%= bug_report_alerts %>
14
+
15
+ 4. Tailwind: add the gem's views to your build.
16
+ - Tailwind v3 (tailwind.config.js content globs): see README "Styling".
17
+ - Tailwind v4: add to app/assets/tailwind/application.css:
18
+ @import "../builds/tailwind/bug_reports_client";
19
+
20
+ 5. Environment variables (or set them in the initializer):
21
+ BUG_REPORT_API_URL e.g. https://bugs.example.com/api
22
+ BUG_REPORT_API_KEY this app's API token
23
+ BUG_REPORT_WEBHOOK_SECRET this app's webhook secret
24
+ APP_HOST public HTTPS origin of this app
25
+
26
+ 6. Review config/initializers/bug_reports_client.rb (source, admin_check,
27
+ ask_severity...) and customise config/bug_report_form.yml if you like.
28
+ ===============================================================================
@@ -0,0 +1,23 @@
1
+ <!--
2
+ Rename this file to config/bug_report_issue.md to control the GitHub issue
3
+ body yourself. Placeholders in {{double braces}} are replaced with the
4
+ report's answers: every field key from config/bug_report_form.yml works, plus
5
+ {{title}}, {{report_type}}, {{severity}}, {{reporter_name}}, {{app_name}} and
6
+ {{screenshots}}. Without this file, the issue body is generated automatically
7
+ from the schema (a heading per answered field). Delete this comment block if
8
+ you activate the template - it would appear in your GitHub issues.
9
+ -->
10
+
11
+ **Severity:** {{severity}} | **Reported by:** {{reporter_name}} ({{app_name}})
12
+
13
+ ## What should happen?
14
+ {{expected_behaviour}}
15
+
16
+ ## What actually happens?
17
+ {{actual_behaviour}}
18
+
19
+ ## Steps to reproduce
20
+ {{steps_to_reproduce}}
21
+
22
+ ## Screenshots
23
+ {{screenshots}}
@@ -0,0 +1,31 @@
1
+ # Configuration for bug_reports_client. Most settings default from
2
+ # environment variables (BUG_REPORT_API_URL, BUG_REPORT_API_KEY,
3
+ # BUG_REPORT_WEBHOOK_SECRET, APP_HOST) - see the gem README for the full
4
+ # reference.
5
+ BugReportsClient.configure do |config|
6
+ # REQUIRED: must match this app's API key name on the bug-reports API and a
7
+ # key in its repo mapping.
8
+ config.source = "<%= Rails.application.class.module_parent_name.underscore %>"
9
+
10
+ # The public HTTPS origin of this app, used for the closure callback URL and
11
+ # screenshot links in GitHub issues. Defaults to ENV["APP_HOST"].
12
+ # config.app_host = "https://myapp.example.com"
13
+
14
+ # Who counts as an admin (can see /bug_reports/all).
15
+ # config.admin_check = ->(user) { user.admin? }
16
+
17
+ # Whether reports come from outside your team (shown on the GitHub issue).
18
+ # config.reporter_external = ->(user) { true }
19
+
20
+ # Consumer-facing apps often hide the severity picker; bugs then submit
21
+ # config.default_severity ("medium") automatically.
22
+ # config.ask_severity = false
23
+
24
+ # Screenshot uploads need an Active Storage service whose URLs are publicly
25
+ # reachable (e.g. S3) - otherwise disable them.
26
+ # config.screenshots_enabled = false
27
+
28
+ # Reporter attributes, if your user model differs from the defaults
29
+ # (User#email and User#name). Symbols or procs are accepted.
30
+ # config.reporter_name_method = ->(user) { "#{user.first_name} #{user.last_name}" }
31
+ end
@@ -0,0 +1,19 @@
1
+ require "rails/generators"
2
+
3
+ module BugReportsClient
4
+ module Generators
5
+ # Copies the engine's views into the host app for full customisation:
6
+ # bin/rails g bug_reports_client:views
7
+ #
8
+ # Copied views shadow the engine's per-file (Rails checks the host first),
9
+ # so you can copy everything and delete what you don't change. Note that
10
+ # copied files no longer receive engine updates.
11
+ class ViewsGenerator < Rails::Generators::Base
12
+ source_root BugReportsClient::Engine.root.join("app/views").to_s
13
+
14
+ def copy_views
15
+ directory "bug_reports_client", "app/views/bug_reports_client"
16
+ end
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bug_reports_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - PSA Squash Tour
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '8.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '8.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: turbo-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ description: 'Adds a fully-featured, customisable bug and feature reporting flow to
42
+ any Rails app: a schema-driven form, screenshot uploads, a my-reports list, and
43
+ signed closure webhooks from the companion bug-reports API which files GitHub issues.'
44
+ email:
45
+ - harry.mattocks@psasquashtour.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - CHANGELOG.md
51
+ - MIT-LICENSE
52
+ - README.md
53
+ - app/assets/tailwind/bug_reports_client/engine.css
54
+ - app/controllers/bug_reports_client/application_controller.rb
55
+ - app/controllers/bug_reports_client/bug_reports_controller.rb
56
+ - app/controllers/bug_reports_client/webhooks_controller.rb
57
+ - app/helpers/bug_reports_client/bug_reports_helper.rb
58
+ - app/javascript/bug_reports_client/controllers/error_summary_controller.js
59
+ - app/javascript/bug_reports_client/controllers/file_limit_controller.js
60
+ - app/javascript/bug_reports_client/controllers/report_type_controller.js
61
+ - app/javascript/bug_reports_client/controllers/screenshot_dropzone_controller.js
62
+ - app/jobs/bug_reports_client/report_error_job.rb
63
+ - app/models/bug_reports_client/application_record.rb
64
+ - app/models/bug_reports_client/bug_report.rb
65
+ - app/models/bug_reports_client/error_event.rb
66
+ - app/models/concerns/bug_reports_client/reporter.rb
67
+ - app/services/bug_reports_client/api_client.rb
68
+ - app/services/bug_reports_client/description_builder.rb
69
+ - app/views/bug_reports_client/bug_reports/_field_checkbox.html.erb
70
+ - app/views/bug_reports_client/bug_reports/_field_select.html.erb
71
+ - app/views/bug_reports_client/bug_reports/_field_text.html.erb
72
+ - app/views/bug_reports_client/bug_reports/_field_textarea.html.erb
73
+ - app/views/bug_reports_client/bug_reports/_filters.html.erb
74
+ - app/views/bug_reports_client/bug_reports/_form.html.erb
75
+ - app/views/bug_reports_client/bug_reports/_pagination.html.erb
76
+ - app/views/bug_reports_client/bug_reports/_rating_badge.html.erb
77
+ - app/views/bug_reports_client/bug_reports/_related_error.html.erb
78
+ - app/views/bug_reports_client/bug_reports/_status_badge.html.erb
79
+ - app/views/bug_reports_client/bug_reports/_type_badge.html.erb
80
+ - app/views/bug_reports_client/bug_reports/all.html.erb
81
+ - app/views/bug_reports_client/bug_reports/edit.html.erb
82
+ - app/views/bug_reports_client/bug_reports/index.html.erb
83
+ - app/views/bug_reports_client/bug_reports/new.html.erb
84
+ - app/views/bug_reports_client/shared/_after_dismiss.turbo_stream.erb
85
+ - app/views/bug_reports_client/shared/_alerts.html.erb
86
+ - config/form_schema.yml
87
+ - config/importmap.rb
88
+ - config/locales/en.yml
89
+ - config/routes.rb
90
+ - db/migrate/20260721000001_create_bug_reports.rb
91
+ - db/migrate/20260723000002_create_bug_report_error_events.rb
92
+ - db/migrate/20260723000003_add_activity_to_bug_report_error_events.rb
93
+ - lib/bug_reports_client.rb
94
+ - lib/bug_reports_client/configuration.rb
95
+ - lib/bug_reports_client/engine.rb
96
+ - lib/bug_reports_client/error_context.rb
97
+ - lib/bug_reports_client/error_reporter.rb
98
+ - lib/bug_reports_client/form_schema.rb
99
+ - lib/bug_reports_client/main_app_routes.rb
100
+ - lib/bug_reports_client/version.rb
101
+ - lib/generators/bug_reports_client/install/install_generator.rb
102
+ - lib/generators/bug_reports_client/install/templates/AFTER_INSTALL
103
+ - lib/generators/bug_reports_client/install/templates/bug_report_issue.md.example
104
+ - lib/generators/bug_reports_client/install/templates/initializer.rb
105
+ - lib/generators/bug_reports_client/views/views_generator.rb
106
+ homepage: https://github.com/Professional-Squash-Association/bug-reports
107
+ licenses:
108
+ - MIT
109
+ metadata:
110
+ homepage_uri: https://github.com/Professional-Squash-Association/bug-reports
111
+ source_code_uri: https://github.com/Professional-Squash-Association/bug-reports
112
+ changelog_uri: https://github.com/Professional-Squash-Association/bug-reports/blob/main/client/CHANGELOG.md
113
+ rubygems_mfa_required: 'true'
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '3.2'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.5.22
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Mountable Rails engine for submitting bug reports and feature requests to
133
+ a central bug-reports API
134
+ test_files: []