flipper-notifications 0.1.9 → 0.1.11
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/.rubocop.yml +3 -0
- data/Gemfile.lock +2 -1
- data/README.md +48 -0
- data/lib/flipper/notifications/configuration.rb +19 -1
- data/lib/flipper/notifications/feature_event.rb +22 -2
- data/lib/flipper/notifications/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b89e1c2fa5d254aebc89291bb50eec14b5687d9ea95f17f061e8f4972cc452f8
|
|
4
|
+
data.tar.gz: 870159e8ebf702200423b873448e8ac63140322fb4dbe6f811c746805ecdbf5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63da6fdb0abb5067d5f1c6dd09e7103c1172fa3e294fb9e30817205ba75986c07c3f4aa9ba84328ac41790306e41d256657fdca09a7751a7135faad149d6ebf4
|
|
7
|
+
data.tar.gz: cf2ead088adc75c0aa2fb4c8c82b818264c89bd9bdd7d551a22dc16acb7808136b3a268f680e72b72069143d62172a0e3df5c3b7f5c3f4823c4263c9b2aba8df
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
flipper-notifications (0.1.
|
|
4
|
+
flipper-notifications (0.1.11)
|
|
5
5
|
activesupport (>= 7, < 8.2)
|
|
6
6
|
flipper (>= 0.24, < 2.0)
|
|
7
7
|
httparty (~> 0.17)
|
|
@@ -104,6 +104,7 @@ PLATFORMS
|
|
|
104
104
|
arm64-darwin-21
|
|
105
105
|
arm64-darwin-23
|
|
106
106
|
arm64-darwin-24
|
|
107
|
+
arm64-darwin-25
|
|
107
108
|
x86_64-linux
|
|
108
109
|
|
|
109
110
|
DEPENDENCIES
|
data/README.md
CHANGED
|
@@ -53,6 +53,54 @@ Flipper::Notifications.configure do |config|
|
|
|
53
53
|
end
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
### Stale State with Cached Adapters
|
|
57
|
+
|
|
58
|
+
Notifications are rendered inside a background job (`WebhookNotificationJob`),
|
|
59
|
+
which may run in a **different process** from the one that changed the feature.
|
|
60
|
+
The message ("The feature is now fully enabled/disabled", the list of groups,
|
|
61
|
+
actors, and percentages) is built by reading the feature's current state at
|
|
62
|
+
job-run time.
|
|
63
|
+
|
|
64
|
+
If your Flipper adapter is fronted by a **per-process cache** — for example an
|
|
65
|
+
in-memory `ActiveSupportCacheStore` layer — the process running the job can hold
|
|
66
|
+
a stale value: enabling a feature in your web process does not invalidate a
|
|
67
|
+
worker's in-memory cache. The notification then reports the wrong state.
|
|
68
|
+
|
|
69
|
+
By default state is read through the global `Flipper`. Point `config.flipper` at
|
|
70
|
+
a cache-free instance backed by your source of truth so notifications always
|
|
71
|
+
render the real value:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
# config/initializers/flipper.rb
|
|
75
|
+
|
|
76
|
+
Flipper::Notifications.configure do |config|
|
|
77
|
+
config.flipper = Flipper.new(Flipper::Adapters::ActiveRecord.new)
|
|
78
|
+
end
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This only affects how notifications **read** state; your application keeps using
|
|
82
|
+
its cached `Flipper` everywhere else.
|
|
83
|
+
|
|
84
|
+
### Slack invalid_blocks Errors
|
|
85
|
+
|
|
86
|
+
Slack limits the size of webhook messages. The Slack API returns a 400 status
|
|
87
|
+
code in these cases with a message of `invalid_blocks`. If your feature is
|
|
88
|
+
enabled for a lot of actors or a lot of groups, the length of the list of
|
|
89
|
+
actor or group names can exceed Slack's limit. To avoid these errors, you
|
|
90
|
+
may configure a character limit sent in webhooks by configuring a
|
|
91
|
+
`webhook_character_limit` in your initializer:
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
# config/initializers/flipper.rb
|
|
95
|
+
|
|
96
|
+
Flipper::Notifications.configure do |config|
|
|
97
|
+
config.webhook_character_limit = 3_000
|
|
98
|
+
end
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
If you set this value, webhook messages will be shortened whenever they
|
|
102
|
+
exceed the configured character limit.
|
|
103
|
+
|
|
56
104
|
### Implementing Your Own Webhooks
|
|
57
105
|
|
|
58
106
|
This gem provides an implementation to send notifications to Slack via an
|
|
@@ -7,14 +7,32 @@ module Flipper
|
|
|
7
7
|
def initialize
|
|
8
8
|
@enabled = false
|
|
9
9
|
@notifiers = []
|
|
10
|
+
@webhook_character_limit = nil
|
|
11
|
+
@flipper = nil
|
|
10
12
|
end
|
|
11
13
|
|
|
12
|
-
attr_accessor :enabled, :notifiers
|
|
14
|
+
attr_accessor :enabled, :notifiers, :webhook_character_limit
|
|
15
|
+
attr_writer :flipper
|
|
13
16
|
|
|
14
17
|
def enabled?
|
|
15
18
|
@enabled
|
|
16
19
|
end
|
|
17
20
|
|
|
21
|
+
# The Flipper instance used to READ feature state when rendering a
|
|
22
|
+
# notification. Defaults to the global `Flipper`.
|
|
23
|
+
#
|
|
24
|
+
# Notifications are rendered in a background job, which may run in a
|
|
25
|
+
# different process from the one that changed the feature. If your Flipper
|
|
26
|
+
# adapter is fronted by a per-process cache (e.g. an in-memory
|
|
27
|
+
# ActiveSupportCacheStore), the reading process can hold a stale value and
|
|
28
|
+
# the message reports the wrong state. Point this at a cache-free instance
|
|
29
|
+
# backed by your source of truth to always render the real value, e.g.:
|
|
30
|
+
#
|
|
31
|
+
# config.flipper = Flipper.new(Flipper::Adapters::ActiveRecord.new)
|
|
32
|
+
def flipper
|
|
33
|
+
@flipper || Flipper
|
|
34
|
+
end
|
|
35
|
+
|
|
18
36
|
end
|
|
19
37
|
end
|
|
20
38
|
end
|
|
@@ -20,7 +20,7 @@ module Flipper
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def initialize(feature_name:, operation:)
|
|
23
|
-
@feature = Flipper.feature(feature_name)
|
|
23
|
+
@feature = Flipper::Notifications.configuration.flipper.feature(feature_name)
|
|
24
24
|
@operation = operation.to_s
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -40,7 +40,7 @@ module Flipper
|
|
|
40
40
|
def feature_enabled_settings_markdown
|
|
41
41
|
return "" unless feature.conditional?
|
|
42
42
|
|
|
43
|
-
[].tap do |settings|
|
|
43
|
+
markdown = [].tap do |settings|
|
|
44
44
|
settings << "The feature is now enabled for:" if feature.conditional?
|
|
45
45
|
|
|
46
46
|
settings << "- Groups: #{to_sentence(feature.enabled_groups.map(&:name).sort)}" if feature.enabled_groups.any?
|
|
@@ -53,6 +53,11 @@ module Flipper
|
|
|
53
53
|
|
|
54
54
|
settings << "- #{feature.percentage_of_time_value}% of the time" if feature.percentage_of_time_value.positive?
|
|
55
55
|
end.join("\n")
|
|
56
|
+
|
|
57
|
+
character_limit = Flipper::Notifications.configuration.webhook_character_limit
|
|
58
|
+
return markdown if character_limit.nil? || markdown.length <= character_limit
|
|
59
|
+
|
|
60
|
+
shortened_feature_enabled_settings_markdown[0...character_limit]
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
def noteworthy?
|
|
@@ -97,6 +102,21 @@ module Flipper
|
|
|
97
102
|
end
|
|
98
103
|
end
|
|
99
104
|
|
|
105
|
+
def shortened_feature_enabled_settings_markdown
|
|
106
|
+
[].tap do |settings|
|
|
107
|
+
settings << "The feature is now enabled for:" if feature.conditional?
|
|
108
|
+
|
|
109
|
+
settings << "#{feature.enabled_groups.size} Groups" if feature.enabled_groups.any?
|
|
110
|
+
settings << "#{feature.actors_value.size} Actors" if feature.actors_value.any?
|
|
111
|
+
|
|
112
|
+
if feature.percentage_of_actors_value.positive?
|
|
113
|
+
settings << "- #{feature.percentage_of_actors_value}% of actors"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
settings << "- #{feature.percentage_of_time_value}% of the time" if feature.percentage_of_time_value.positive?
|
|
117
|
+
end.join("\n")
|
|
118
|
+
end
|
|
119
|
+
|
|
100
120
|
end
|
|
101
121
|
end
|
|
102
122
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flipper-notifications
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joel Lubrano
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
256
256
|
- !ruby/object:Gem::Version
|
|
257
257
|
version: '0'
|
|
258
258
|
requirements: []
|
|
259
|
-
rubygems_version: 3.
|
|
259
|
+
rubygems_version: 3.4.10
|
|
260
260
|
signing_key:
|
|
261
261
|
specification_version: 4
|
|
262
262
|
summary: Rails-compatible Slack notifications for Flipper feature flags
|