ideasbugs 1.3.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edf399697a638eaa2a13340445fdde4c862f924f4ab6f330c3d973aa2c5a7747
4
- data.tar.gz: 6760c8e7f1ed291a38e77ffb7a4d836b85542da3627f130af198af79e9c38dc4
3
+ metadata.gz: 594b7409df6ee7d74454512af1f913f18a7f9ad3befd898e8914d47da0962129
4
+ data.tar.gz: d984c12493ecc5a100e00f8e091f1f00181cca84dbeb4ac399ef11f222c816e0
5
5
  SHA512:
6
- metadata.gz: bfa830068047cb3f390a47a4d5841ffd4dee8911c9ca410c64e3553301b7fe261474db8ee079f53bad2990103274c0b4f6ba18ab94c412e02f87d42b29c9cff6
7
- data.tar.gz: e8da203df04a8e43f0444e92203201d93ad7be19097759b04470318aec9ee688092ea8f4661da82b8167c9bd6bb85ed66eea661caa89a62be70feddff05f4aec
6
+ metadata.gz: 98a6e17b3a7429697a53bbb780e610f73bfac3e22f14819bb45ee746ad98ee71ba885c5b447b084a9b1b98c826a2665b3da51c920156d72fcb00d698223e5a4c
7
+ data.tar.gz: 10abf57ad59a31f68f347e0c5a1278900a68c3c3080bcf00b8843dcc6bccbb143a95871c42345aa5b9d61c25f9509fa538ed8f4d7818713ad5edda87c01651f7
data/AGENTS.md CHANGED
@@ -155,7 +155,7 @@ Everything is optional; a fresh install works with zero config. Full list with c
155
155
  | No Feedback button | `ideasbugs_tag` missing from the rendered layout, `config.enabled` false, or `show_button = false` with no opener of your own |
156
156
  | Submissions rejected with an invalid-token error | The layout is missing `csrf_meta_tags` |
157
157
  | No screenshot upload control | Active Storage not installed, or `screenshots = false` |
158
- | `ideasbugs:tenant` fails on a duplicate column | It is an upgrade generator for pre-tenant installs; a fresh install already has the column |
158
+ | `ideasbugs:tenant`, `ideasbugs:duplicates` or `ideasbugs:author_type` fails on a duplicate column | They are upgrade generators for older installs; a fresh install already has the column |
159
159
  | `undefined local variable current_user` in the initializer | A gate lambda treated its argument as a controller. It is a `request` |
160
160
 
161
161
  ---
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.4.0] - 2026-11-10
6
+
7
+ - **Typed authors.** `Feedback.submit` and the widget store the author's class
8
+ in a new `author_type` column next to `author_id`, so a host that files
9
+ feedback from more than one kind of record (a user, an API token, an
10
+ organisation) can tell `User #7` from `Token #7`. Active Record models are
11
+ stored by `polymorphic_name`. The dashboard shows `User #7` when the host
12
+ stores no `author_label`.
13
+ - **Cost:** one nullable string column, no foreign key. Existing installs run
14
+ `bin/rails generate ideasbugs:author_type && bin/rails db:migrate`; until
15
+ then attribution works exactly as in 1.3. Existing rows keep a nil type,
16
+ because the gem cannot know which class their ids belong to: backfill it
17
+ yourself if they share one. No initializer change.
18
+
5
19
  ## [1.3.1] - 2026-11-10
6
20
 
7
21
  - Fix the dashboard queue under Rails edge Ractor requests. 1.3.0's
data/README.md CHANGED
@@ -222,7 +222,9 @@ end
222
222
 
223
223
  Each row stores `kind`, `section`, `message`, `status` (`open` / `in_review` /
224
224
  `resolved`), `page_url`, `user_agent`, an optional `tenant`, and optional
225
- `author_id` / `author_label`. Screenshots are Active Storage attachments
225
+ `author_id` / `author_type` / `author_label`. `author_type` is the author's
226
+ class (`polymorphic_name` for Active Record models), so ids from different
227
+ kinds of author cannot be confused. Screenshots are Active Storage attachments
226
228
  (`feedback.screenshots`). `duplicate_of_id` points a duplicate at its original.
227
229
 
228
230
  ## Duplicates
@@ -250,6 +252,11 @@ dashboard and keeps its own `status` for when it is unmarked.
250
252
  `bin/rails generate ideasbugs:duplicates && bin/rails db:migrate`. Until then
251
253
  the dashboard works as before, without duplicate controls.
252
254
 
255
+ **Upgrading from 1.3 or earlier:** run
256
+ `bin/rails generate ideasbugs:author_type && bin/rails db:migrate` to store
257
+ the author's class. Until then `author_type` stays empty. Existing rows keep a
258
+ nil type; backfill it if all your authors share one class.
259
+
253
260
  ## File feedback from your own API
254
261
 
255
262
  The widget is one way in. If your app already has an API, one endpoint lets
@@ -297,7 +304,8 @@ curl -X POST https://app.example.com/api/feedback \
297
304
  the record: check `persisted?` and `errors`. Your endpoint still owns:
298
305
 
299
306
  - **Authentication.** The gem has no tokens of its own. Attribute feedback to
300
- the token's user so the dashboard shows who sent it.
307
+ the token's user so the dashboard shows who sent it. A token that belongs to
308
+ no user can be the author itself: `author_type` records which it was.
301
309
  - **The gates.** `config.enabled` and `config.rate_limit` guard the widget's
302
310
  endpoint only. Apply the same rule and a throttle here.
303
311
  - **The tenant.** Pass the key `config.tenant` would return for that user, or
@@ -358,7 +366,7 @@ The following are the model and integration contracts that 1.x will keep
358
366
  stable under semantic versioning:
359
367
 
360
368
  - `Ideasbugs::Feedback`, including `kind`, `section`, `message`, `status`,
361
- `page_url`, `user_agent`, `tenant`, `author_id`, `author_label`, timestamps,
369
+ `page_url`, `user_agent`, `tenant`, `author_id`, `author_type`, `author_label`, timestamps,
362
370
  `STATUSES`, status helpers/scopes, `newest_first`, `for_tenant`, gated
363
371
  `screenshots`, `Feedback.submit`, and the duplicate API (`duplicate_of`,
364
372
  `duplicates`, `duplicate?`, `originals`, `mark_duplicate_of!`,
@@ -55,6 +55,11 @@ module Ideasbugs
55
55
  column_names.include?('duplicate_of_id')
56
56
  end
57
57
 
58
+ # Installs before 1.4 lack the column until they run `ideasbugs:author_type`.
59
+ def self.tracks_author_type?
60
+ column_names.include?('author_type')
61
+ end
62
+
58
63
  SUBMITTED_ATTRIBUTES = %i[kind section message page_url].freeze
59
64
 
60
65
  # Files feedback the way the widget does: privacy-filtered page URL, author
@@ -140,9 +145,18 @@ module Ideasbugs
140
145
  return unless author
141
146
 
142
147
  self.author_id = author.id.to_s if author.respond_to?(:id)
148
+ klass = author.class
149
+ self.author_type = klass.try(:polymorphic_name) || klass.name if self.class.tracks_author_type?
143
150
  self.author_label = Ideasbugs.config.author_label.call(author)
144
151
  end
145
152
 
153
+ # What the dashboard shows when the host stores no label: "User #7".
154
+ def author_reference
155
+ return author_label if author_label.present?
156
+
157
+ [attributes['author_type'], "##{author_id}"].compact.join(' ') if author_id.present?
158
+ end
159
+
146
160
  # Attaches uploads, or returns the error that rejects them. No screenshots
147
161
  # at all is fine.
148
162
  def attach_screenshots(files)
@@ -53,9 +53,9 @@
53
53
  <dt><%= t('ideasbugs.section', default: 'Section') %></dt>
54
54
  <dd><%= feedback.section %></dd>
55
55
  <% end %>
56
- <% if feedback.author_label.present? || feedback.author_id.present? %>
56
+ <% if (author = feedback.author_reference) %>
57
57
  <dt><%= t('ideasbugs.dashboard.from', default: 'From') %></dt>
58
- <dd><%= feedback.author_label.presence || "##{feedback.author_id}" %></dd>
58
+ <dd><%= author %></dd>
59
59
  <% end %>
60
60
  <% if feedback.page_url.present? %>
61
61
  <dt><%= t('ideasbugs.dashboard.page', default: 'Page') %></dt>
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+ require 'rails/generators/active_record'
5
+ require_relative '../migration_helpers'
6
+
7
+ module Ideasbugs
8
+ module Generators
9
+ # For apps that installed ideasbugs before 1.4: adds the nullable
10
+ # `author_type` column to ideasbugs_feedbacks, so `author_id` names a
11
+ # record of a known class. A fresh install already gets it. Existing rows
12
+ # keep a nil type; the gem cannot know which class their ids belong to.
13
+ #
14
+ # bin/rails generate ideasbugs:author_type && bin/rails db:migrate
15
+ class AuthorTypeGenerator < Rails::Generators::Base
16
+ include ActiveRecord::Generators::Migration
17
+ include MigrationHelpers
18
+
19
+ source_root File.expand_path('templates', __dir__)
20
+
21
+ desc 'Adds the author_type column to ideasbugs_feedbacks (author type upgrade).'
22
+
23
+ def create_migration_file
24
+ migration_template 'add_author_type_to_ideasbugs_feedbacks.rb.tt',
25
+ 'db/migrate/add_author_type_to_ideasbugs_feedbacks.rb'
26
+ end
27
+
28
+ def post_install
29
+ say "\nauthor_type column queued. Run `rails db:migrate`. Existing rows keep", :green
30
+ say 'a nil type: backfill it yourself if all your authors share one class.'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddAuthorTypeToIdeasbugsFeedbacks < ActiveRecord::Migration<%= migration_version %>
4
+ def change
5
+ add_column :ideasbugs_feedbacks, :author_type, :string
6
+ end
7
+ end
@@ -10,6 +10,7 @@ class CreateIdeasbugsFeedbacks < ActiveRecord::Migration<%= migration_version %>
10
10
  t.string :page_url
11
11
  t.string :user_agent
12
12
  t.string :author_id
13
+ t.string :author_type
13
14
  t.string :author_label
14
15
  t.string :tenant # opaque per-tenant key; nil = single global board
15
16
  t.references :duplicate_of<%= reference_type_option %>, index: true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ideasbugs
4
- VERSION = '1.3.1'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ideasbugs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov
@@ -99,6 +99,8 @@ files:
99
99
  - docs/screenshots/dashboard-light.png
100
100
  - docs/screenshots/widget-dark.png
101
101
  - docs/screenshots/widget-light.png
102
+ - lib/generators/ideasbugs/author_type/author_type_generator.rb
103
+ - lib/generators/ideasbugs/author_type/templates/add_author_type_to_ideasbugs_feedbacks.rb.tt
102
104
  - lib/generators/ideasbugs/duplicates/duplicates_generator.rb
103
105
  - lib/generators/ideasbugs/duplicates/templates/add_duplicate_of_to_ideasbugs_feedbacks.rb.tt
104
106
  - lib/generators/ideasbugs/install/install_generator.rb