Skip to content

Commit ba4ec8c

Browse files
authored
Remove inline user configuration option (#223)
1 parent 8b7ee10 commit ba4ec8c

File tree

7 files changed

+16
-56
lines changed

7 files changed

+16
-56
lines changed

contract-tests/client_entity.rb

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def initialize(log, config)
3131
opts[:all_attributes_private] = !!events[:allAttributesPrivate]
3232
opts[:private_attribute_names] = events[:globalPrivateAttributes]
3333
opts[:flush_interval] = (events[:flushIntervalMs] / 1_000) unless events[:flushIntervalMs].nil?
34-
opts[:inline_users_in_events] = events[:inlineUsers] || false
3534
else
3635
opts[:send_events] = false
3736
end

lib/ldclient-rb/config.rb

-10
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class Config
3434
# @option opts [Boolean] :send_events (true) See {#send_events}.
3535
# @option opts [Integer] :user_keys_capacity (1000) See {#user_keys_capacity}.
3636
# @option opts [Float] :user_keys_flush_interval (300) See {#user_keys_flush_interval}.
37-
# @option opts [Boolean] :inline_users_in_events (false) See {#inline_users_in_events}.
3837
# @option opts [Object] :data_source See {#data_source}.
3938
# @option opts [Boolean] :diagnostic_opt_out (false) See {#diagnostic_opt_out?}.
4039
# @option opts [Float] :diagnostic_recording_interval (900) See {#diagnostic_recording_interval}.
@@ -65,7 +64,6 @@ def initialize(opts = {})
6564
@send_events = opts.has_key?(:send_events) ? opts[:send_events] : Config.default_send_events
6665
@user_keys_capacity = opts[:user_keys_capacity] || Config.default_user_keys_capacity
6766
@user_keys_flush_interval = opts[:user_keys_flush_interval] || Config.default_user_keys_flush_interval
68-
@inline_users_in_events = opts[:inline_users_in_events] || false
6967
@data_source = opts[:data_source]
7068
@diagnostic_opt_out = opts.has_key?(:diagnostic_opt_out) && opts[:diagnostic_opt_out]
7169
@diagnostic_recording_interval = opts.has_key?(:diagnostic_recording_interval) && opts[:diagnostic_recording_interval] > Config.minimum_diagnostic_recording_interval ?
@@ -249,14 +247,6 @@ def offline?
249247
#
250248
attr_reader :user_keys_flush_interval
251249

252-
#
253-
# Whether to include full user details in every analytics event. By default, events will only
254-
# include the user key, except for one "index" event that provides the full details for the user.
255-
# The only reason to change this is if you are using the Analytics Data Stream.
256-
# @return [Boolean]
257-
#
258-
attr_reader :inline_users_in_events
259-
260250
#
261251
# An object that is responsible for receiving feature flag data from LaunchDarkly. By default,
262252
# the client uses its standard polling or streaming implementation; this is customizable for

lib/ldclient-rb/events.rb

+4-20
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,10 @@ def dispatch_event(event, outbox)
311311
will_add_full_event = true
312312
end
313313

314-
# For each user we haven't seen before, we add an index event - unless this is already
315-
# an identify event for that user.
316-
unless will_add_full_event && @config.inline_users_in_events
317-
if !event.context.nil? && !notice_context(event.context) && !event.is_a?(LaunchDarkly::Impl::IdentifyEvent)
318-
outbox.add_event(LaunchDarkly::Impl::IndexEvent.new(event.timestamp, event.context))
319-
end
314+
# For each context we haven't seen before, we add an index event - unless this is already
315+
# an identify event for that context.
316+
if !event.context.nil? && !notice_context(event.context) && !event.is_a?(LaunchDarkly::Impl::IdentifyEvent)
317+
outbox.add_event(LaunchDarkly::Impl::IndexEvent.new(event.timestamp, event.context))
320318
end
321319

322320
outbox.add_event(event) if will_add_full_event
@@ -453,7 +451,6 @@ class EventOutputFormatter
453451
ANONYMOUS_USER_CONTEXT_KIND = 'anonymousUser'
454452

455453
def initialize(config)
456-
@inline_users = config.inline_users_in_events
457454
@context_filter = LaunchDarkly::Impl::ContextFilter.new(config.all_attributes_private, config.private_attribute_names)
458455
end
459456

@@ -560,18 +557,5 @@ def make_output_events(events, summary)
560557
features: flags,
561558
}
562559
end
563-
564-
private def set_opt_context_kind(out, user)
565-
out[:contextKind] = ANONYMOUS_USER_CONTEXT_KIND if !user.nil? && user[:anonymous]
566-
end
567-
568-
private def set_user_or_user_key(out, user)
569-
if @inline_users
570-
out[:user] = @context_filter.filter(user)
571-
else
572-
key = user[:key]
573-
out[:userKey] = key.is_a?(String) ? key : key.to_s
574-
end
575-
end
576560
end
577561
end

lib/ldclient-rb/impl/context.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require "erb"
2+
13
module LaunchDarkly
24
module Impl
35
module Context

lib/ldclient-rb/impl/diagnostic_events.rb

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def self.make_config_data(config)
7373
diagnosticRecordingIntervalMillis: self.seconds_to_millis(config.diagnostic_recording_interval),
7474
eventsCapacity: config.capacity,
7575
eventsFlushIntervalMillis: self.seconds_to_millis(config.flush_interval),
76-
inlineUsersInEvents: config.inline_users_in_events,
7776
pollingIntervalMillis: self.seconds_to_millis(config.poll_interval),
7877
socketTimeoutMillis: self.seconds_to_millis(config.read_timeout),
7978
streamingDisabled: !config.stream?,

spec/diagnostic_events_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def expected_default_config
3131
diagnosticRecordingIntervalMillis: Config.default_diagnostic_recording_interval * 1000,
3232
eventsCapacity: Config.default_capacity,
3333
eventsFlushIntervalMillis: Config.default_flush_interval * 1000,
34-
inlineUsersInEvents: false,
3534
pollingIntervalMillis: Config.default_poll_interval * 1000,
3635
socketTimeoutMillis: Config.default_read_timeout * 1000,
3736
streamingDisabled: false,
@@ -64,7 +63,6 @@ def expected_default_config
6463
[ { diagnostic_recording_interval: 9999 }, { diagnosticRecordingIntervalMillis: 9999000 } ],
6564
[ { capacity: 4000 }, { eventsCapacity: 4000 } ],
6665
[ { flush_interval: 46 }, { eventsFlushIntervalMillis: 46000 } ],
67-
[ { inline_users_in_events: true }, { inlineUsersInEvents: true } ],
6866
[ { poll_interval: 999 }, { pollingIntervalMillis: 999000 } ],
6967
[ { read_timeout: 46 }, { socketTimeoutMillis: 46000 } ],
7068
[ { stream: false }, { streamingDisabled: true } ],

spec/events_spec.rb

+10-22
Original file line numberDiff line numberDiff line change
@@ -80,27 +80,15 @@ def with_processor_and_sender(config)
8080
end
8181

8282
it "filters context in feature event" do
83-
config = LaunchDarkly::Config.new(default_config_opts.merge(all_attributes_private: true, inline_users_in_events: true))
83+
config = LaunchDarkly::Config.new(default_config_opts.merge(all_attributes_private: true))
8484
with_processor_and_sender(config) do |ep, sender|
8585
flag = { key: "flagkey", version: 11 }
8686
ep.record_eval_event(context, 'flagkey', 11, 1, 'value', nil, nil, true)
8787

88-
output = flush_and_get_events(ep, sender)
89-
expect(output).to contain_exactly(
90-
eq(feature_event(flag, context, 1, 'value', true)),
91-
include(:kind => "summary")
92-
)
93-
end
94-
end
95-
96-
it "still generates index event if inline_users is true but feature event was not tracked" do
97-
config = LaunchDarkly::Config.new(default_config_opts.merge(inline_users_in_events: true))
98-
with_processor_and_sender(config) do |ep, sender|
99-
ep.record_eval_event(context, 'flagkey', 11, 1, 'value', nil, nil, false)
100-
10188
output = flush_and_get_events(ep, sender)
10289
expect(output).to contain_exactly(
10390
eq(index_event(config, context)),
91+
eq(feature_event(flag, context, 1, 'value')),
10492
include(:kind => "summary")
10593
)
10694
end
@@ -197,8 +185,8 @@ def with_processor_and_sender(config)
197185
output = flush_and_get_events(ep, sender)
198186
expect(output).to contain_exactly(
199187
eq(index_event(default_config, context)),
200-
eq(feature_event(flag1, context, 1, 'value', false, starting_timestamp)),
201-
eq(feature_event(flag2, context, 1, 'value', false, starting_timestamp + 1)),
188+
eq(feature_event(flag1, context, 1, 'value', starting_timestamp)),
189+
eq(feature_event(flag2, context, 1, 'value', starting_timestamp + 1)),
202190
include(:kind => "summary")
203191
)
204192
end
@@ -250,13 +238,14 @@ def with_processor_and_sender(config)
250238
end
251239

252240
it "filters context in custom event" do
253-
config = LaunchDarkly::Config.new(default_config_opts.merge(all_attributes_private: true, inline_users_in_events: true))
241+
config = LaunchDarkly::Config.new(default_config_opts.merge(all_attributes_private: true))
254242
with_processor_and_sender(config) do |ep, sender|
255243
ep.record_custom_event(context, 'eventkey')
256244

257245
output = flush_and_get_events(ep, sender)
258246
expect(output).to contain_exactly(
259-
eq(custom_event(context, 'eventkey', nil, nil, true))
247+
eq(index_event(config, context)),
248+
eq(custom_event(context, 'eventkey', nil, nil))
260249
)
261250
end
262251
end
@@ -421,7 +410,7 @@ def identify_event(config, context, timestamp = starting_timestamp)
421410
# @param timestamp [Integer]
422411
# @return [Hash]
423412
#
424-
def feature_event(flag, context, variation, value, inline_user = false, timestamp = starting_timestamp)
413+
def feature_event(flag, context, variation, value, timestamp = starting_timestamp)
425414
out = {
426415
kind: 'feature',
427416
creationDate: timestamp,
@@ -462,13 +451,12 @@ def debug_event(config, flag, context, variation, value, timestamp = starting_ti
462451
# @param key [String]
463452
# @param data [any]
464453
# @param metric_value [any]
465-
# @param timestamp [Integer]
466454
# @return [Hash]
467455
#
468-
def custom_event(context, key, data, metric_value, inline_user = false, timestamp = starting_timestamp)
456+
def custom_event(context, key, data, metric_value)
469457
out = {
470458
kind: "custom",
471-
creationDate: timestamp,
459+
creationDate: starting_timestamp,
472460
contextKeys: context.keys,
473461
key: key,
474462
}

0 commit comments

Comments
 (0)