journaled 6.2.9 → 7.0.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: 5002dd1919359cc60cb0c65f79d447369e8b3c0ee877fc8595de9a1f96401fd1
4
- data.tar.gz: 1f89c0f22aef4e6592bdae5f441f9bd58384770ac88fc293763476b1ddba5c5b
3
+ metadata.gz: 7da8b60f6a6330d804f54a41a3e0ed2fcd4884e811542599088a9b9d7a9cef29
4
+ data.tar.gz: 489fa98f872666cb5c01a0edc0e4bed2fbc1ed481516cc3abfd363e4f9059f12
5
5
  SHA512:
6
- metadata.gz: 1c50ce659c7a04e06c33b42b58f3b3b096e03ad4869ce6537597a7031044e7d1b9d2292062fbcf2823aa2c16fd6b6a2ae2bcf0968364dee2be8ca6e0f45127e3
7
- data.tar.gz: ac0447714457d670a3ee9f505e4aecd48b23065cb5a5bceeb8500b0c5739bc9fad78d9a96005a95bdb4347e6abe17f16bed4c9716b85f9bdcbd10bc2aff25970
6
+ metadata.gz: 2402f321700808215b5b4ecd9c316e575be1edecd043a9ee81b620178548f57ac54e8cf2646de707166162afe7c353f3fde4341222451bcfb7c30b35791b8291
7
+ data.tar.gz: 9c00a20d76b5ac214083d74460a99988513cb33f03d42ad75bf5a7690fc935a6cb04b9413a5d773a96b5f18948e02c988d77b256b5abade72c338b20f4f915cb
data/README.md CHANGED
@@ -359,6 +359,17 @@ record is created or destroyed, an event will be sent to Kinesis with the follow
359
359
  * `actor` - a string (usually a rails global_id) representing who
360
360
  performed the action.
361
361
 
362
+ Pass `tagged: true` to also include a `tags` field sourced from the current
363
+ [tagged event](#tagged-events) context (e.g. `Journaled.tag!`/`Journaled.tagged`):
364
+
365
+ ```ruby
366
+ journal_changes_to :email, :first_name, :last_name, as: :identity_change, tagged: true
367
+ ```
368
+
369
+ This is useful for capturing metadata (like a session or visitor ID) that isn't
370
+ itself a column on the model. It defaults to `false` to preserve the existing
371
+ event shape for models that don't opt in.
372
+
362
373
  Callback-bypassing database methods like `update_all`, `delete_all`,
363
374
  `update_columns` and `delete` are intercepted and will require an
364
375
  additional `force: true` argument if they would interfere with change
@@ -847,6 +858,19 @@ gem version.
847
858
 
848
859
  As such, **we always recommend upgrading only one major version at a time.**
849
860
 
861
+ ### Upgrading from 6.x
862
+
863
+ `journal_changes_to` now accepts a `tagged:` option (default `false`). This is
864
+ opt-in at the Ruby level, so no application code needs to change to upgrade.
865
+
866
+ However, the `journaled/change` JSON schema (`journaled_schemas/journaled/change.json`)
867
+ now permits an optional `tags` property on every `Journaled::Change` event,
868
+ regardless of whether any particular model opts in. If you (or a downstream
869
+ consumer of this stream) validate `Journaled::Change` payloads against a copy
870
+ of this schema, or against your own stricter schema, that schema needs to
871
+ tolerate a `tags` field being present, since any model in the producing app
872
+ could begin sending it independently of your consumer.
873
+
850
874
  ### Upgrading from 4.3.0
851
875
 
852
876
  Versions of Journaled prior to 5.0 would enqueue events one at a time, but 5.0
@@ -56,14 +56,18 @@ module Journaled::Changes
56
56
  end
57
57
 
58
58
  class_methods do
59
- def journal_changes_to(*attribute_names, as:, enqueue_with: {})
59
+ def journal_changes_to(*attribute_names, as:, enqueue_with: {}, tagged: false)
60
60
  if attribute_names.empty? || attribute_names.any? { |n| !n.is_a?(Symbol) }
61
61
  raise "one or more symbol attribute_name arguments is required"
62
62
  end
63
63
 
64
64
  raise "as: must be a symbol" unless as.is_a?(Symbol)
65
65
 
66
- _journaled_change_definitions << Journaled::ChangeDefinition.new(attribute_names: attribute_names, logical_operation: as)
66
+ _journaled_change_definitions << Journaled::ChangeDefinition.new(
67
+ attribute_names: attribute_names,
68
+ logical_operation: as,
69
+ tagged: tagged,
70
+ )
67
71
  journaled_attribute_names.concat(attribute_names)
68
72
  journaled_enqueue_opts.merge!(enqueue_with)
69
73
  end
@@ -26,7 +26,8 @@ class Journaled::Change
26
26
  changes:,
27
27
  journaled_stream_name:,
28
28
  journaled_enqueue_opts:,
29
- actor:)
29
+ actor:,
30
+ tagged: false)
30
31
  @table_name = table_name
31
32
  @record_id = record_id
32
33
  @database_operation = database_operation
@@ -35,5 +36,18 @@ class Journaled::Change
35
36
  @journaled_stream_name = journaled_stream_name
36
37
  @journaled_enqueue_opts = journaled_enqueue_opts
37
38
  @actor = actor
39
+ @tagged = tagged
40
+ end
41
+
42
+ def tagged?
43
+ @tagged
44
+ end
45
+
46
+ def tags
47
+ Journaled::Current.tags
48
+ end
49
+
50
+ def journaled_attributes
51
+ tagged? ? super.merge(tags:) : super
38
52
  end
39
53
  end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Journaled::ChangeDefinition
4
- attr_reader :attribute_names, :logical_operation
4
+ attr_reader :attribute_names, :logical_operation, :tagged
5
5
 
6
- def initialize(attribute_names:, logical_operation:)
6
+ def initialize(attribute_names:, logical_operation:, tagged: false)
7
7
  @attribute_names = attribute_names.map(&:to_s)
8
8
  @logical_operation = logical_operation
9
+ @tagged = tagged
9
10
  @validated = false
10
11
  end
11
12
 
@@ -3,7 +3,7 @@
3
3
  class Journaled::ChangeWriter
4
4
  attr_reader :model, :change_definition
5
5
 
6
- delegate :attribute_names, :logical_operation, to: :change_definition
6
+ delegate :attribute_names, :logical_operation, :tagged, to: :change_definition
7
7
 
8
8
  def initialize(model:, change_definition:)
9
9
  @model = model
@@ -33,6 +33,7 @@ class Journaled::ChangeWriter
33
33
  journaled_stream_name: journaled_stream_name,
34
34
  journaled_enqueue_opts: model.journaled_enqueue_opts,
35
35
  actor: actor_uri,
36
+ tagged: tagged,
36
37
  )
37
38
  end
38
39
 
@@ -41,6 +41,10 @@
41
41
  },
42
42
  "actor": {
43
43
  "type": ["string", null]
44
+ },
45
+ "tags": {
46
+ "type": "object",
47
+ "additionalProperties": true
44
48
  }
45
49
  }
46
50
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Journaled
4
- VERSION = "6.2.9"
4
+ VERSION = "7.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: journaled
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.9
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Lipson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2026-07-09 00:00:00.000000000 Z
14
+ date: 2026-08-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activejob
@@ -89,7 +89,7 @@ dependencies:
89
89
  requirements:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: '7.2'
92
+ version: '8.0'
93
93
  - - "<"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '8.1'
@@ -99,7 +99,7 @@ dependencies:
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '7.2'
102
+ version: '8.0'
103
103
  - - "<"
104
104
  - !ruby/object:Gem::Version
105
105
  version: '8.1'
@@ -319,14 +319,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
319
319
  requirements:
320
320
  - - ">="
321
321
  - !ruby/object:Gem::Version
322
- version: '3.2'
322
+ version: '3.3'
323
323
  required_rubygems_version: !ruby/object:Gem::Requirement
324
324
  requirements:
325
325
  - - ">="
326
326
  - !ruby/object:Gem::Version
327
327
  version: '0'
328
328
  requirements: []
329
- rubygems_version: 3.4.10
329
+ rubygems_version: 3.5.22
330
330
  signing_key:
331
331
  specification_version: 4
332
332
  summary: Journaling for Betterment apps.