Skip to content

Commit 697d76d

Browse files
authored
Merge pull request #459 from splitio/dw/SDKS-6908
[DW] split_client updated logs
2 parents e7c5898 + 1ad874e commit 697d76d

3 files changed

Lines changed: 23 additions & 23 deletions

File tree

lib/splitclient-rb/clients/split_client.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class SplitClient
1111
#
1212
# Creates a new split client instance that connects to split.io API.
1313
#
14-
# @param api_key [String] the API key for your split account
14+
# @param sdk_key [String] the SDK key for your split account
1515
#
1616
# @return [SplitIoClient] split.io client instance
17-
def initialize(api_key, repositories, status_manager, config, impressions_manager, telemetry_evaluation_producer)
18-
@api_key = api_key
17+
def initialize(sdk_key, repositories, status_manager, config, impressions_manager, telemetry_evaluation_producer)
18+
@api_key = sdk_key
1919
@splits_repository = repositories[:splits]
2020
@segments_repository = repositories[:segments]
2121
@impressions_repository = repositories[:impressions]
@@ -103,8 +103,8 @@ def track(key, traffic_type_name, event_type, value = nil, properties = nil)
103103

104104
if ready? && !@config.localhost_mode && !@splits_repository.traffic_type_exists(traffic_type_name)
105105
@config.logger.warn("track: Traffic Type #{traffic_type_name} " \
106-
"does not have any corresponding Splits in this environment, make sure you're tracking " \
107-
'your events to a valid traffic type defined in the Split console')
106+
"does not have any corresponding feature flags in this environment, make sure you're tracking " \
107+
'your events to a valid traffic type defined in the Split user interface')
108108
end
109109

110110
@events_repository.add(key.to_s, traffic_type_name.downcase, event_type.to_s, (Time.now.to_f * 1000).to_i, value, properties, properties_size)
@@ -147,10 +147,10 @@ def sanitize_split_names(calling_method, split_names)
147147
if (split_name.is_a?(String) || split_name.is_a?(Symbol)) && !split_name.empty?
148148
true
149149
elsif split_name.is_a?(String) && split_name.empty?
150-
@config.logger.warn("#{calling_method}: you passed an empty split_name, split_name must be a non-empty String or a Symbol")
150+
@config.logger.warn("#{calling_method}: you passed an empty feature_flag_name, flag name must be a non-empty String or a Symbol")
151151
false
152152
else
153-
@config.logger.warn("#{calling_method}: you passed an invalid split_name, split_name must be a non-empty String or a Symbol")
153+
@config.logger.warn("#{calling_method}: you passed an invalid feature_flag_name, flag name must be a non-empty String or a Symbol")
154154
false
155155
end
156156
end
@@ -200,7 +200,7 @@ def treatments(key, split_names, attributes = {}, calling_method = 'get_treatmen
200200
sanitized_split_names = sanitize_split_names(calling_method, split_names)
201201

202202
if sanitized_split_names.empty?
203-
@config.logger.error("#{calling_method}: split_names must be a non-empty Array")
203+
@config.logger.error("#{calling_method}: feature_flag_names must be a non-empty Array")
204204
return {}
205205
end
206206

@@ -258,7 +258,7 @@ def treatment(
258258
sanitized_split_name = split_name.to_s.strip
259259

260260
if split_name.to_s != sanitized_split_name
261-
@config.logger.warn("#{calling_method}: split_name #{split_name} has extra whitespace, trimming")
261+
@config.logger.warn("#{calling_method}: feature_flag_name #{split_name} has extra whitespace, trimming")
262262
split_name = sanitized_split_name
263263
end
264264

@@ -271,7 +271,7 @@ def treatment(
271271

272272
if split.nil? && ready?
273273
@config.logger.warn("#{calling_method}: you passed #{split_name} that " \
274-
'does not exist in this environment, please double check what Splits exist in the web console')
274+
'does not exist in this environment, please double check what feature flags exist in the Split user interface')
275275

276276
return parsed_treatment(multiple, control_treatment.merge({ label: Engine::Models::Label::NOT_FOUND }))
277277
end

lib/splitclient-rb/validators.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def valid_bucketing_key?(method, key, bucketing_key)
156156

157157
def valid_split_names?(method, split_names)
158158
unless !split_names.nil? && split_names.is_a?(Array)
159-
@config.logger.error("#{method}: split_names must be a non-empty Array")
159+
@config.logger.error("#{method}: feature_flag_names must be a non-empty Array")
160160
return false
161161
end
162162

spec/engine_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
it 'trims split_name and logs warning when extra whitespaces' do
283283
split_name = ' test_feature '
284284
expect(subject.get_treatment('fake_user_id_1', split_name)).to eq 'on'
285-
expect(log.string).to include "get_treatment: split_name #{split_name} has extra whitespace, trimming"
285+
expect(log.string).to include "get_treatment: feature_flag_name #{split_name} has extra whitespace, trimming"
286286
end
287287

288288
it 'returns CONTROL when non Hash attributes' do
@@ -295,8 +295,8 @@
295295
expect(subject.get_treatment('random_user_id', 'non_existing_feature'))
296296
.to eq SplitIoClient::Engine::Models::Treatment::CONTROL
297297
expect(log.string).to include 'get_treatment: you passed non_existing_feature ' \
298-
'that does not exist in this environment, please double check what Splits exist ' \
299-
'in the web console'
298+
'that does not exist in this environment, please double check what feature flags exist ' \
299+
'in the Split user interface'
300300
end
301301

302302
it 'returns CONTROL with NOT_READY label when not ready' do
@@ -366,17 +366,17 @@
366366

367367
it 'returns empty hash on nil split_names' do
368368
expect(subject.get_treatments('random_user_id', nil)).to be_nil
369-
expect(log.string).to include 'get_treatments: split_names must be a non-empty Array'
369+
expect(log.string).to include 'get_treatments: feature_flag_names must be a non-empty Array'
370370
end
371371

372372
it 'returns empty hash when no Array split_names' do
373373
expect(subject.get_treatments('random_user_id', Object.new)).to be_nil
374-
expect(log.string).to include 'get_treatments: split_names must be a non-empty Array'
374+
expect(log.string).to include 'get_treatments: feature_flag_names must be a non-empty Array'
375375
end
376376

377377
it 'returns empty hash on empty array split_names' do
378378
expect(subject.get_treatments('random_user_id', [])).to eq({})
379-
expect(log.string).to include 'get_treatments: split_names must be a non-empty Array'
379+
expect(log.string).to include 'get_treatments: feature_flag_names must be a non-empty Array'
380380
end
381381

382382
it 'sanitizes split_names removing repeating and nil split_names' do
@@ -386,14 +386,14 @@
386386

387387
it 'warns when non string split_names' do
388388
expect(subject.get_treatments('random_user_id', [Object.new, Object.new])).to eq({})
389-
expect(log.string).to include 'get_treatments: you passed an invalid split_name, ' \
390-
'split_name must be a non-empty String or a Symbol'
389+
expect(log.string).to include 'get_treatments: you passed an invalid feature_flag_name, ' \
390+
'flag name must be a non-empty String or a Symbol'
391391
end
392392

393393
it 'warns when empty split_names' do
394394
expect(subject.get_treatments('random_user_id', [''])).to eq({})
395-
expect(log.string).to include 'get_treatments: you passed an empty split_name, ' \
396-
'split_name must be a non-empty String or a Symbol'
395+
expect(log.string).to include 'get_treatments: you passed an empty feature_flag_name, ' \
396+
'flag name must be a non-empty String or a Symbol'
397397
end
398398
end
399399

@@ -953,8 +953,8 @@
953953

954954
expect(subject.track('123', traffic_type_name, 'event_type', 123)).to be true
955955
expect(log.string).to include "track: Traffic Type #{traffic_type_name} " \
956-
"does not have any corresponding Splits in this environment, make sure you're tracking " \
957-
'your events to a valid traffic type defined in the Split console'
956+
"does not have any corresponding feature flags in this environment, make sure you're tracking " \
957+
'your events to a valid traffic type defined in the Split user interface'
958958
end
959959
end
960960
end

0 commit comments

Comments
 (0)