flagsmith 4.1.1 → 5.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.
@@ -37,15 +37,15 @@ module Flagsmith
37
37
 
38
38
  MATCHING_FUNCTIONS = {
39
39
  EQUAL => ->(other_value, self_value) { other_value == self_value },
40
- GREATER_THAN => ->(other_value, self_value) { other_value > self_value },
41
- GREATER_THAN_INCLUSIVE => ->(other_value, self_value) { other_value >= self_value },
42
- LESS_THAN => ->(other_value, self_value) { other_value < self_value },
43
- LESS_THAN_INCLUSIVE => ->(other_value, self_value) { other_value <= self_value },
40
+ GREATER_THAN => ->(other_value, self_value) { (other_value || false) && other_value > self_value },
41
+ GREATER_THAN_INCLUSIVE => ->(other_value, self_value) { (other_value || false) && other_value >= self_value },
42
+ LESS_THAN => ->(other_value, self_value) { (other_value || false) && other_value < self_value },
43
+ LESS_THAN_INCLUSIVE => ->(other_value, self_value) { (other_value || false) && other_value <= self_value },
44
44
  NOT_EQUAL => ->(other_value, self_value) { other_value != self_value },
45
- CONTAINS => ->(other_value, self_value) { other_value.include? self_value },
45
+ CONTAINS => ->(other_value, self_value) { (other_value || false) && other_value.include?(self_value) },
46
46
 
47
- NOT_CONTAINS => ->(other_value, self_value) { !other_value.include? self_value },
48
- REGEX => ->(other_value, self_value) { other_value.match? self_value }
47
+ NOT_CONTAINS => ->(other_value, self_value) { (other_value || false) && !other_value.include?(self_value) },
48
+ REGEX => ->(other_value, self_value) { (other_value || false) && other_value.to_s.match?(self_value) }
49
49
  }.freeze
50
50
 
51
51
  def initialize(operator:, value:, property: nil)
@@ -55,30 +55,48 @@ module Flagsmith
55
55
  end
56
56
 
57
57
  def match_trait_value?(trait_value)
58
- # handle some exceptions
59
- trait_value = Semantic::Version.new(trait_value.gsub(/:semver$/, '')) if @value.is_a?(String) && @value.match?(/:semver$/)
58
+ trait_value = parse_semver_trait_value(trait_value)
59
+ return false if trait_value.nil?
60
60
 
61
61
  return match_in_value(trait_value) if @operator == IN
62
62
  return match_modulo_value(trait_value) if @operator == MODULO
63
+ return MATCHING_FUNCTIONS[REGEX]&.call(trait_value, @value) if @operator == REGEX
63
64
 
65
+ match_with_type_conversion(trait_value)
66
+ end
67
+
68
+ def parse_semver_trait_value(trait_value)
69
+ return trait_value unless @value.is_a?(String) && @value.match?(/:semver$/)
70
+
71
+ Semantic::Version.new(trait_value.to_s.gsub(/:semver$/, ''))
72
+ rescue ArgumentError, Semantic::Version::ValidationFailed
73
+ nil
74
+ end
75
+
76
+ def match_with_type_conversion(trait_value)
64
77
  type_as_trait_value = format_to_type_of(trait_value)
65
78
  formatted_value = type_as_trait_value ? type_as_trait_value.call(@value) : @value
66
-
67
79
  MATCHING_FUNCTIONS[operator]&.call(trait_value, formatted_value)
68
80
  end
69
81
 
70
- # rubocop:disable Metrics/AbcSize
82
+ TYPE_CONVERTERS = {
83
+ 'String' => ->(v) { v.to_s },
84
+ 'Semantic::Version' => ->(v) { Semantic::Version.new(v.to_s.gsub(/:semver$/, '')) },
85
+ 'TrueClass' => ->(v) { ['True', 'true', 'TRUE', true, 1, '1'].include?(v) },
86
+ 'FalseClass' => ->(v) { !['False', 'false', 'FALSE', false].include?(v) },
87
+ 'Integer' => lambda { |v|
88
+ i = v.to_i
89
+ i.to_s == v.to_s ? i : v
90
+ },
91
+ 'Float' => lambda { |v|
92
+ f = v.to_f
93
+ f.to_s == v.to_s ? f : v
94
+ }
95
+ }.freeze
96
+
71
97
  def format_to_type_of(input)
72
- {
73
- 'String' => ->(v) { v.to_s },
74
- 'Semantic::Version' => ->(v) { Semantic::Version.new(v.to_s.gsub(/:semver$/, '')) },
75
- 'TrueClass' => ->(v) { ['True', 'true', 'TRUE', true, 1, '1'].include?(v) },
76
- 'FalseClass' => ->(v) { !['False', 'false', 'FALSE', false, 0, '0'].include?(v) },
77
- 'Integer' => ->(v) { v.to_i },
78
- 'Float' => ->(v) { v.to_f }
79
- }[input.class.to_s]
98
+ TYPE_CONVERTERS[input.class.to_s]
80
99
  end
81
- # rubocop:enable Metrics/AbcSize
82
100
 
83
101
  def match_modulo_value(trait_value)
84
102
  divisor, remainder = @value.split('|')
@@ -88,9 +106,25 @@ module Flagsmith
88
106
  end
89
107
 
90
108
  def match_in_value(trait_value)
91
- return @value.split(',').include?(trait_value.to_s) if trait_value.is_a?(String) || trait_value.is_a?(Integer)
109
+ return false if invalid_in_value?(trait_value)
110
+ return @value.include?(trait_value.to_s) if @value.is_a?(Array)
92
111
 
93
- false
112
+ parse_and_match_string_value(trait_value)
113
+ end
114
+
115
+ def invalid_in_value?(trait_value)
116
+ trait_value.nil? || [TrueClass, FalseClass].any? { |klass| trait_value.is_a?(klass) }
117
+ end
118
+
119
+ def parse_and_match_string_value(trait_value) # rubocop:disable Metrics/AbcSize
120
+ return @value.to_s.split(',').include?(trait_value.to_s) unless @value.is_a?(String)
121
+
122
+ parsed = JSON.parse(@value)
123
+ return parsed.include?(trait_value.to_s) if parsed.is_a?(Array)
124
+
125
+ @value.to_s.split(',').include?(trait_value.to_s)
126
+ rescue JSON::ParserError
127
+ @value.to_s.split(',').include?(trait_value.to_s)
94
128
  end
95
129
 
96
130
  class << self
@@ -31,6 +31,7 @@ module Flagsmith
31
31
  faraday.headers['Accept'] = 'application/json'
32
32
  faraday.headers['Content-Type'] = 'application/json'
33
33
  faraday.headers['X-Environment-Key'] = config.environment_key
34
+ faraday.headers['User-Agent'] = Flagsmith::SDK::Utils.user_agent
34
35
  faraday.headers.merge(config.custom_headers)
35
36
  end
36
37
 
@@ -4,10 +4,13 @@ module Flagsmith
4
4
  # Config options shared around Engine
5
5
  class Config
6
6
  DEFAULT_API_URL = 'https://edge.api.flagsmith.com/api/v1/'
7
+ DEFAULT_REALTIME_API_URL = 'https://realtime.flagsmith.com/'
8
+
7
9
  OPTIONS = %i[
8
10
  environment_key api_url custom_headers request_timeout_seconds enable_local_evaluation
9
11
  environment_refresh_interval_seconds retries enable_analytics default_flag_handler
10
- offline_mode offline_handler polling_manager_failure_limit logger
12
+ offline_mode offline_handler polling_manager_failure_limit
13
+ realtime_api_url enable_realtime_updates logger
11
14
  ].freeze
12
15
 
13
16
  # Available Configs
@@ -40,6 +43,9 @@ module Flagsmith
40
43
  # the entire environment, project, flags, etc.
41
44
  # +polling_manager_failure_limit+ - An integer to control how long to suppress errors in
42
45
  # the polling manager for local evaluation mode.
46
+ # +realtime_api_url+ - Override the realtime api URL to communicate with a
47
+ # non-standard realtime endpoint.
48
+ # +enable_realtime_updates+ - A boolean to enable realtime updates.
43
49
  # +logger+ - Pass your logger, default is Logger.new($stdout)
44
50
  #
45
51
  attr_reader(*OPTIONS)
@@ -62,6 +68,10 @@ module Flagsmith
62
68
  @offline_mode
63
69
  end
64
70
 
71
+ def realtime_mode?
72
+ @enable_realtime_updates
73
+ end
74
+
65
75
  def environment_flags_url
66
76
  'flags/'
67
77
  end
@@ -92,6 +102,9 @@ module Flagsmith
92
102
  @offline_mode = opts.fetch(:offline_mode, false)
93
103
  @offline_handler = opts[:offline_handler]
94
104
  @polling_manager_failure_limit = opts.fetch(:polling_manager_failure_limit, 10)
105
+ @realtime_api_url = opts.fetch(:realtime_api_url, Flagsmith::Config::DEFAULT_REALTIME_API_URL)
106
+ @realtime_api_url << '/' unless @realtime_api_url.end_with? '/'
107
+ @enable_realtime_updates = opts.fetch(:enable_realtime_updates, false)
95
108
  @logger = options.fetch(:logger, Logger.new($stdout).tap { |l| l.level = :debug })
96
109
  end
97
110
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
@@ -32,12 +32,13 @@ module Flagsmith
32
32
 
33
33
  # 'live' Flag class as returned by API or local evaluation
34
34
  class Flag < BaseFlag
35
- attr_reader :feature_name, :feature_id
35
+ attr_reader :feature_name, :feature_id, :reason
36
36
 
37
- def initialize(feature_name:, enabled:, value:, feature_id:)
37
+ def initialize(feature_name:, enabled:, value:, feature_id:, reason: nil)
38
38
  super(enabled: enabled, value: value, default: false)
39
39
  @feature_name = feature_name
40
40
  @feature_id = feature_id
41
+ @reason = reason
41
42
  end
42
43
 
43
44
  def <=>(other)
@@ -54,7 +55,8 @@ module Flagsmith
54
55
  feature_name: feature_name,
55
56
  value: value,
56
57
  enabled: enabled,
57
- default: default
58
+ default: default,
59
+ reason: reason
58
60
  }
59
61
  end
60
62
 
@@ -71,7 +73,7 @@ module Flagsmith
71
73
  def from_api(json_flag_data)
72
74
  new(
73
75
  enabled: json_flag_data[:enabled],
74
- value: json_flag_data[:feature_state_value] || json_flag_data[:value],
76
+ value: json_flag_data.fetch(:feature_state_value) { json_flag_data[:value] },
75
77
  feature_name: json_flag_data.dig(:feature, :name),
76
78
  feature_id: json_flag_data.dig(:feature, :id)
77
79
  )
@@ -172,15 +174,27 @@ module Flagsmith
172
174
  )
173
175
  end
174
176
 
175
- def from_feature_state_models(feature_states, identity_id: nil, **args)
176
- to_flag_object = lambda { |feature_state, acc|
177
- acc[normalize_key(feature_state.feature.name)] =
178
- Flagsmith::Flags::Flag.from_feature_state_model(feature_state, identity_id)
177
+ def from_evaluation_result(evaluation_result, **args)
178
+ to_flag_object = lambda { |flag_result, acc|
179
+ id = flag_result.dig(:metadata, :id)
180
+ if id.nil?
181
+ raise Flagsmith::ClientError,
182
+ "FlagResult metadata.id is missing for feature \"#{flag_result[:name]}\". This indicates a bug in the SDK, please report it."
183
+ end
184
+
185
+ acc[flag_result[:name]] = Collection.map_evaluated_flag_to_flag_result(flag_result, id)
179
186
  }
180
187
 
181
- new(
182
- feature_states.each_with_object({}, &to_flag_object),
183
- **args
188
+ new(evaluation_result[:flags].each_value.each_with_object({}, &to_flag_object), **args)
189
+ end
190
+
191
+ def map_evaluated_flag_to_flag_result(flag_result, id)
192
+ Flagsmith::Flags::Flag.new(
193
+ feature_name: flag_result[:name],
194
+ enabled: flag_result[:enabled],
195
+ value: flag_result[:value],
196
+ feature_id: id,
197
+ reason: flag_result[:reason]
184
198
  )
185
199
  end
186
200
 
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+ require 'faraday'
5
+ require 'json'
6
+
7
+ module Flagsmith
8
+ # Ruby client for realtime access to flagsmith.com
9
+ class RealtimeClient
10
+ attr_accessor :running
11
+
12
+ def initialize(config)
13
+ @config = config
14
+ @thread = nil
15
+ @running = false
16
+ @main = nil
17
+ end
18
+
19
+ def endpoint
20
+ "#{@config.realtime_api_url}sse/environments/#{@main.environment.api_key}/stream"
21
+ end
22
+
23
+ def listen(main, remaining_attempts: Float::INFINITY, retry_interval: 0.5) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
24
+ last_updated_at = 0
25
+ @main = main
26
+ @running = true
27
+ @thread = Thread.new do
28
+ while @running && remaining_attempts.positive?
29
+ remaining_attempts -= 1
30
+ @config.logger.warn 'Beginning to pull down realtime endpoint'
31
+ begin
32
+ sleep retry_interval
33
+ # Open connection to SSE endpoint
34
+ Faraday.new(url: endpoint).get do |req|
35
+ req.options.timeout = nil # Keep connection alive indefinitely
36
+ req.options.open_timeout = 10
37
+ end.body.each_line do |line| # rubocop:disable Style/MultilineBlockChain
38
+ # SSE protocol: Skip non-event lines
39
+ next if line.strip.empty? || line.start_with?(':')
40
+
41
+ # Parse SSE fields
42
+ next unless line.start_with?('data: ')
43
+
44
+ data = JSON.parse(line[6..].strip)
45
+ updated_at = data['updated_at']
46
+ next unless updated_at > last_updated_at
47
+
48
+ @config.logger.info "Realtime updating environment from #{last_updated_at} to #{updated_at}"
49
+ @main.update_environment
50
+ last_updated_at = updated_at
51
+ end
52
+ rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e
53
+ @config.logger.warn "Connection failed: #{e.message}. Retrying in #{retry_interval} seconds..."
54
+ rescue StandardError => e
55
+ @config.logger.error "Error: #{e.message}. Retrying in #{retry_interval} seconds..."
56
+ end
57
+ end
58
+ end
59
+
60
+ @running = false
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flagsmith
4
+ module SDK
5
+ # Utility functions
6
+ module Utils
7
+ FLAGSMITH_USER_AGENT = 'flagsmith-ruby-sdk'
8
+ FLAGSMITH_UNKNOWN_VERSION = 'unknown'
9
+
10
+ module_function
11
+
12
+ # Returns the user agent string for HTTP requests
13
+ # @return [String] user agent in format "flagsmith-ruby-sdk/version"
14
+ def user_agent
15
+ "#{FLAGSMITH_USER_AGENT}/#{version}"
16
+ end
17
+
18
+ # Returns the SDK version
19
+ # @return [String] version string or 'unknown' if not available
20
+ def version
21
+ return Flagsmith::VERSION if defined?(Flagsmith::VERSION)
22
+
23
+ FLAGSMITH_UNKNOWN_VERSION
24
+ rescue StandardError
25
+ FLAGSMITH_UNKNOWN_VERSION
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flagsmith
4
- VERSION = '4.1.1'
4
+ VERSION = '5.0.0'
5
5
  end
data/lib/flagsmith.rb CHANGED
@@ -7,15 +7,19 @@ require 'faraday/retry'
7
7
  # This is the patch to use slice in earler versions
8
8
  require 'flagsmith/hash_slice'
9
9
 
10
+ require 'flagsmith/version'
11
+
10
12
  require 'flagsmith/sdk/analytics_processor'
11
13
  require 'flagsmith/sdk/api_client'
12
14
  require 'flagsmith/sdk/config'
13
15
  require 'flagsmith/sdk/errors'
14
16
  require 'flagsmith/sdk/intervals'
17
+ require 'flagsmith/sdk/utils'
15
18
  require 'flagsmith/sdk/pooling_manager'
16
19
  require 'flagsmith/sdk/models/flags'
17
20
  require 'flagsmith/sdk/models/segments'
18
21
  require 'flagsmith/sdk/offline_handlers'
22
+ require 'flagsmith/sdk/realtime_client'
19
23
 
20
24
  require 'flagsmith/engine/core'
21
25
 
@@ -46,6 +50,7 @@ module Flagsmith
46
50
  # :environment_key, :api_url, :custom_headers, :request_timeout_seconds, :enable_local_evaluation,
47
51
  # :environment_refresh_interval_seconds, :retries, :enable_analytics, :default_flag_handler,
48
52
  # :offline_mode, :offline_handler, :polling_manager_failure_limit
53
+ # :realtime_api_url, :enable_realtime_updates, :logger
49
54
  #
50
55
  # You can see full description in the Flagsmith::Config
51
56
 
@@ -59,11 +64,11 @@ module Flagsmith
59
64
  @identity_overrides_by_identifier = {}
60
65
 
61
66
  validate_offline_mode!
67
+ validate_realtime_mode!
62
68
 
63
69
  api_client
64
70
  analytics_processor
65
71
  environment_data_polling_manager
66
- engine
67
72
  load_offline_handler
68
73
  end
69
74
 
@@ -78,12 +83,19 @@ module Flagsmith
78
83
  'Cannot use offline_handler and default_flag_handler at the same time.'
79
84
  end
80
85
 
86
+ def validate_realtime_mode!
87
+ return unless @config.realtime_mode? && !@config.local_evaluation?
88
+
89
+ raise Flagsmith::ClientError,
90
+ 'The enable_realtime_updates config param requires a matching enable_local_evaluation param.'
91
+ end
92
+
81
93
  def api_client
82
94
  @api_client ||= Flagsmith::ApiClient.new(@config)
83
95
  end
84
96
 
85
- def engine
86
- @engine ||= Flagsmith::Engine::Engine.new
97
+ def realtime_client
98
+ @realtime_client ||= Flagsmith::RealtimeClient.new(@config)
87
99
  end
88
100
 
89
101
  def analytics_processor
@@ -104,6 +116,14 @@ module Flagsmith
104
116
  def environment_data_polling_manager
105
117
  return nil unless @config.local_evaluation?
106
118
 
119
+ # Bypass the environment data polling manager if realtime
120
+ # is present in the configuration.
121
+ if @config.realtime_mode?
122
+ update_environment
123
+ realtime_client.listen self unless realtime_client.running
124
+ return
125
+ end
126
+
107
127
  update_environment if @environment_data_polling_manager.nil?
108
128
 
109
129
  @environment_data_polling_manager ||= Flagsmith::EnvironmentDataPollingManager.new(
@@ -148,11 +168,13 @@ module Flagsmith
148
168
  # environment, e.g. email address, username, uuid
149
169
  # traits { key => value } is a dictionary of traits to add / update on the identity in
150
170
  # Flagsmith, e.g. { "num_orders": 10 }
171
+ # in lieu of a trait value, a trait coniguration dictionary can be provided,
172
+ # e.g. { "num_orders": { "value": 10, "transient": true } }
151
173
  # returns Flags object holding all the flags for the given identity.
152
- def get_identity_flags(identifier, **traits)
174
+ def get_identity_flags(identifier, transient = false, **traits) # rubocop:disable Style/OptionalBooleanParameter
153
175
  return get_identity_flags_from_document(identifier, traits) if environment
154
176
 
155
- get_identity_flags_from_api(identifier, traits)
177
+ get_identity_flags_from_api(identifier, traits, transient)
156
178
  end
157
179
 
158
180
  def feature_enabled?(feature_name, default: false)
@@ -184,21 +206,33 @@ module Flagsmith
184
206
  end
185
207
 
186
208
  def get_identity_segments(identifier, traits = {})
187
- unless environment
188
- raise Flagsmith::ClientError,
189
- 'Local evaluation or offline handler is required to obtain identity segments.'
190
- end
209
+ raise Flagsmith::ClientError, 'Local evaluation or offline handler is required to obtain identity segments.' unless environment
191
210
 
192
211
  identity_model = get_identity_model(identifier, traits)
193
- segment_models = engine.get_identity_segments(environment, identity_model)
194
- segment_models.map { |sm| Flagsmith::Segments::Segment.new(id: sm.id, name: sm.name) }.compact
212
+ context = Flagsmith::Engine::Mappers.get_evaluation_context(environment, identity_model)
213
+ raise Flagsmith::ClientError, 'Local evaluation required to obtain identity segments' unless context
214
+
215
+ evaluation_result = Flagsmith::Engine.get_evaluation_result(context)
216
+ evaluation_result[:segments].filter_map do |segment_result|
217
+ id = segment_result.dig(:metadata, :id)
218
+ Flagsmith::Segments::Segment.new(id: id, name: segment_result[:name]) if id
219
+ end
195
220
  end
196
221
 
197
222
  private
198
223
 
199
- def environment_flags_from_document
200
- Flagsmith::Flags::Collection.from_feature_state_models(
201
- engine.get_environment_feature_states(environment),
224
+ def environment_flags_from_document # rubocop:disable Metrics/MethodLength
225
+ context = Flagsmith::Engine::Mappers.get_evaluation_context(environment)
226
+
227
+ unless context
228
+ raise Flagsmith::ClientError,
229
+ 'Unable to get flags. No environment present.'
230
+ end
231
+
232
+ evaluation_result = Flagsmith::Engine.get_evaluation_result(context)
233
+
234
+ Flagsmith::Flags::Collection.from_evaluation_result(
235
+ evaluation_result,
202
236
  analytics_processor: analytics_processor,
203
237
  default_flag_handler: default_flag_handler,
204
238
  offline_handler: offline_handler
@@ -207,12 +241,13 @@ module Flagsmith
207
241
 
208
242
  def get_identity_flags_from_document(identifier, traits = {})
209
243
  identity_model = get_identity_model(identifier, traits)
244
+ context = Flagsmith::Engine::Mappers.get_evaluation_context(environment, identity_model)
245
+ raise Flagsmith::ClientError, 'Unable to get flags. No environment present.' unless context
210
246
 
211
- Flagsmith::Flags::Collection.from_feature_state_models(
212
- engine.get_identity_feature_states(environment, identity_model),
213
- identity_id: identity_model.composite_key,
214
- analytics_processor: analytics_processor,
215
- default_flag_handler: default_flag_handler,
247
+ evaluation_result = Flagsmith::Engine.get_evaluation_result(context)
248
+ Flagsmith::Flags::Collection.from_evaluation_result(
249
+ evaluation_result,
250
+ analytics_processor: analytics_processor, default_flag_handler: default_flag_handler,
216
251
  offline_handler: offline_handler
217
252
  )
218
253
  end
@@ -253,16 +288,16 @@ module Flagsmith
253
288
  end
254
289
 
255
290
  # rubocop:disable Metrics/MethodLength
256
- def get_identity_flags_from_api(identifier, traits = {})
291
+ def get_identity_flags_from_api(identifier, traits, transient)
257
292
  if offline_handler
258
293
  begin
259
- process_identity_flags_from_api(identifier, traits)
294
+ process_identity_flags_from_api(identifier, traits, transient)
260
295
  rescue StandardError
261
296
  get_identity_flags_from_document(identifier, traits)
262
297
  end
263
298
  else
264
299
  begin
265
- process_identity_flags_from_api(identifier, traits)
300
+ process_identity_flags_from_api(identifier, traits, transient)
266
301
  rescue StandardError
267
302
  if default_flag_handler
268
303
  return Flagsmith::Flags::Collection.new(
@@ -276,8 +311,8 @@ module Flagsmith
276
311
  end
277
312
  # rubocop:enable Metrics/MethodLength
278
313
 
279
- def process_identity_flags_from_api(identifier, traits = {})
280
- data = generate_identities_data(identifier, traits)
314
+ def process_identity_flags_from_api(identifier, traits, transient)
315
+ data = generate_identities_data(identifier, traits, transient)
281
316
  json_response = api_client.post(@config.identities_url, data.to_json).body
282
317
 
283
318
  Flagsmith::Flags::Collection.from_api(
@@ -311,10 +346,13 @@ module Flagsmith
311
346
  end
312
347
  # rubocop:enable Metrics/MethodLength
313
348
 
314
- def generate_identities_data(identifier, traits = {})
349
+ def generate_identities_data(identifier, traits, transient)
315
350
  {
316
351
  identifier: identifier,
317
- traits: traits.map { |key, value| { trait_key: key, trait_value: value } }
352
+ transient: transient,
353
+ traits: traits.map do |key, value|
354
+ value.is_a?(Hash) ? { trait_key: key, trait_value: value[:value], transient: value[:transient] || false } : { trait_key: key, trait_value: value }
355
+ end
318
356
  }
319
357
  end
320
358
  end
@@ -0,0 +1,62 @@
1
+ {
2
+ "bootstrap-sha": "2535f5d5bf16e4cb1ca30e10dd2e925eb62dbd9b",
3
+ "packages": {
4
+ ".": {
5
+ "release-type": "ruby",
6
+ "changelog-path": "CHANGELOG.md",
7
+ "bump-minor-pre-major": false,
8
+ "bump-patch-for-minor-pre-major": false,
9
+ "draft": false,
10
+ "prerelease": false,
11
+ "include-component-in-tag": false
12
+ }
13
+ },
14
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
15
+ "changelog-sections": [
16
+ {
17
+ "type": "feat",
18
+ "hidden": false,
19
+ "section": "Features"
20
+ },
21
+ {
22
+ "type": "fix",
23
+ "hidden": false,
24
+ "section": "Bug Fixes"
25
+ },
26
+ {
27
+ "type": "ci",
28
+ "hidden": false,
29
+ "section": "CI"
30
+ },
31
+ {
32
+ "type": "docs",
33
+ "hidden": false,
34
+ "section": "Docs"
35
+ },
36
+ {
37
+ "type": "deps",
38
+ "hidden": false,
39
+ "section": "Dependency Updates"
40
+ },
41
+ {
42
+ "type": "perf",
43
+ "hidden": false,
44
+ "section": "Performance Improvements"
45
+ },
46
+ {
47
+ "type": "refactor",
48
+ "hidden": false,
49
+ "section": "Refactoring"
50
+ },
51
+ {
52
+ "type": "test",
53
+ "hidden": false,
54
+ "section": "Tests"
55
+ },
56
+ {
57
+ "type": "chore",
58
+ "hidden": false,
59
+ "section": "Other"
60
+ }
61
+ ]
62
+ }