ldclient-rb 5.5.3 → 5.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e5398b81dc216177803939d535b130edbb0361a
4
- data.tar.gz: 4c50f29da29da753db0a36064c29a22191960808
3
+ metadata.gz: 59ce5212d9da56a89b81f777b4167917a888dd81
4
+ data.tar.gz: f6bae254bfd984bf899629c7a12a42771742b49a
5
5
  SHA512:
6
- metadata.gz: 894d4f29200b6a5df70608942f15223a9b9d5bdeb426913f3afe9feb7d23b02b2ef544874ba7c39570b3f8e8c098caafab638ff9b779b9aec69ca444d1115b62
7
- data.tar.gz: 41c088debbc36d16b7518b20af0ddc4c9b488e0da16b9e465d573ab6e715f00612fb53ee4fe492692cf0d065aa16c3e85ba2d17314c1c326110415ac4667b310
6
+ metadata.gz: f53b38fe2d082a621b728ba98479468923ddf5cd05a6bb0ddf05632210524d149dde39041055c5294fc6186e7fe908b175612926c8c6c107eb22213db79d3b2f
7
+ data.tar.gz: fa22bf113cca0bc31a91cba3d218063a246b47209ea55482962a6ff6f7c8db18625d560388d62e1ef06b8244ee9847dec0ae5f41d9b5d16528a1639d9529d168
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is this a support request?**
11
+ This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/) and clicking "submit a request", or by emailing support@launchdarkly.com.
12
+
13
+ Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.
14
+
15
+ **Describe the bug**
16
+ A clear and concise description of what the bug is.
17
+
18
+ **To reproduce**
19
+ Steps to reproduce the behavior.
20
+
21
+ **Expected behavior**
22
+ A clear and concise description of what you expected to happen.
23
+
24
+ **Logs**
25
+ If applicable, add any log output related to your problem.
26
+
27
+ **SDK version**
28
+ The version of this SDK that you are using.
29
+
30
+ **Language version, developer tools**
31
+ For instance, Go 1.11 or Ruby 2.5.3. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too.
32
+
33
+ **OS/platform**
34
+ For instance, Ubuntu 16.04, Windows 10, or Android 4.0.3. If your code is running in a browser, please also include the browser type and version.
35
+
36
+ **Additional context**
37
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I would love to see the SDK [...does something new...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context about the feature request here.
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to the LaunchDarkly Ruby SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## [5.5.4] - 2019-03-29
6
+ ### Fixed:
7
+ - Fixed a missing `require` that could sometimes cause a `NameError` to be thrown when starting the client, depending on what other gems were installed. This bug was introduced in version 5.5.3. ([#129](https://github.com/launchdarkly/ruby-client/issues/129))
8
+ - When an analytics event was generated for a feature flag because it is a prerequisite for another flag that was evaluated, the user data was being omitted from the event. ([#128](https://github.com/launchdarkly/ruby-client/issues/128))
9
+ - If `track` or `identify` is called without a user, the SDK now logs a warning, and does not send an analytics event to LaunchDarkly (since it would not be processed without a user).
10
+ - Added a link from the SDK readme to the guide regarding the client initialization.
11
+
5
12
  ## [5.5.3] - 2019-02-13
6
13
  ### Changed:
7
14
  - The SDK previously used the `faraday` and `net-http-persistent` gems for all HTTP requests other than streaming connections. Since `faraday` lacks a stable version and has a known issue with character encoding, and `net-http-persistent` is no longer maintained, these have both been removed. This should not affect any SDK functionality.
data/README.md CHANGED
@@ -33,6 +33,8 @@ require 'ldclient-rb'
33
33
  client = LaunchDarkly::LDClient.new("your_sdk_key")
34
34
  ```
35
35
 
36
+ *NOTE: Please refer to [our documentation](https://docs.launchdarkly.com/docs/ruby-sdk-reference#section-initializing-ldclient-using-spring-unicorn-or-puma) for additional instructions on how to use LaunchDarkly with [Spring](https://github.com/rails/spring), [Unicorn](https://bogomips.org/unicorn/), or [Puma](https://github.com/puma/puma).*
37
+
36
38
  ### Ruby on Rails
37
39
 
38
40
  1. Add `gem 'ldclient-rb'` to your Gemfile and `bundle install`
@@ -263,6 +263,7 @@ module LaunchDarkly
263
263
  event = {
264
264
  kind: "feature",
265
265
  key: prereq_key,
266
+ user: user,
266
267
  variation: prereq_res.variation_index,
267
268
  value: prereq_res.value,
268
269
  version: prereq_flag[:version],
@@ -272,7 +273,7 @@ module LaunchDarkly
272
273
  }
273
274
  events.push(event)
274
275
  rescue => exn
275
- Util.log_exception(logger, "Error evaluating prerequisite flag \"#{prereq_key}\" for flag \"{flag[:key]}\"", exn)
276
+ Util.log_exception(logger, "Error evaluating prerequisite flag \"#{prereq_key}\" for flag \"#{flag[:key]}\"", exn)
276
277
  prereq_ok = false
277
278
  end
278
279
  end
@@ -211,6 +211,10 @@ module LaunchDarkly
211
211
  # @return [void]
212
212
  #
213
213
  def identify(user)
214
+ if !user || user[:key].nil?
215
+ @config.logger.warn("Identify called with nil user or nil user key!")
216
+ return
217
+ end
214
218
  sanitize_user(user)
215
219
  @event_processor.add_event(kind: "identify", key: user[:key], user: user)
216
220
  end
@@ -229,6 +233,10 @@ module LaunchDarkly
229
233
  # @return [void]
230
234
  #
231
235
  def track(event_name, user, data)
236
+ if !user || user[:key].nil?
237
+ @config.logger.warn("Track called with nil user or nil user key!")
238
+ return
239
+ end
232
240
  sanitize_user(user)
233
241
  @event_processor.add_event(kind: "custom", key: event_name, user: user, data: data)
234
242
  end
@@ -1,3 +1,4 @@
1
+ require "net/http"
1
2
  require "uri"
2
3
 
3
4
  module LaunchDarkly
@@ -1,3 +1,3 @@
1
1
  module LaunchDarkly
2
- VERSION = "5.5.3"
2
+ VERSION = "5.5.4"
3
3
  end
@@ -127,7 +127,7 @@ describe LaunchDarkly::Evaluation do
127
127
  detail = LaunchDarkly::EvaluationDetail.new('b', 1,
128
128
  { kind: 'PREREQUISITE_FAILED', prerequisiteKey: 'feature1' })
129
129
  events_should_be = [{
130
- kind: 'feature', key: 'feature1', variation: nil, value: nil, version: 2, prereqOf: 'feature0',
130
+ kind: 'feature', key: 'feature1', user: user, variation: nil, value: nil, version: 2, prereqOf: 'feature0',
131
131
  trackEvents: nil, debugEventsUntilDate: nil
132
132
  }]
133
133
  result = evaluate(flag, user, features, logger)
@@ -159,7 +159,7 @@ describe LaunchDarkly::Evaluation do
159
159
  detail = LaunchDarkly::EvaluationDetail.new('b', 1,
160
160
  { kind: 'PREREQUISITE_FAILED', prerequisiteKey: 'feature1' })
161
161
  events_should_be = [{
162
- kind: 'feature', key: 'feature1', variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
162
+ kind: 'feature', key: 'feature1', user: user, variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
163
163
  trackEvents: nil, debugEventsUntilDate: nil
164
164
  }]
165
165
  result = evaluate(flag, user, features, logger)
@@ -189,7 +189,7 @@ describe LaunchDarkly::Evaluation do
189
189
  detail = LaunchDarkly::EvaluationDetail.new('b', 1,
190
190
  { kind: 'PREREQUISITE_FAILED', prerequisiteKey: 'feature1' })
191
191
  events_should_be = [{
192
- kind: 'feature', key: 'feature1', variation: 0, value: 'd', version: 2, prereqOf: 'feature0',
192
+ kind: 'feature', key: 'feature1', user: user, variation: 0, value: 'd', version: 2, prereqOf: 'feature0',
193
193
  trackEvents: nil, debugEventsUntilDate: nil
194
194
  }]
195
195
  result = evaluate(flag, user, features, logger)
@@ -218,7 +218,7 @@ describe LaunchDarkly::Evaluation do
218
218
  user = { key: 'x' }
219
219
  detail = LaunchDarkly::EvaluationDetail.new('a', 0, { kind: 'FALLTHROUGH' })
220
220
  events_should_be = [{
221
- kind: 'feature', key: 'feature1', variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
221
+ kind: 'feature', key: 'feature1', user: user, variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
222
222
  trackEvents: nil, debugEventsUntilDate: nil
223
223
  }]
224
224
  result = evaluate(flag, user, features, logger)
@@ -8,7 +8,8 @@ describe LaunchDarkly::LDClient do
8
8
  subject.new("secret", offline_config)
9
9
  end
10
10
  let(:null_data) { LaunchDarkly::NullUpdateProcessor.new }
11
- let(:config) { LaunchDarkly::Config.new({send_events: false, data_source: null_data}) }
11
+ let(:logger) { double().as_null_object }
12
+ let(:config) { LaunchDarkly::Config.new({ send_events: false, data_source: null_data, logger: logger }) }
12
13
  let(:client) do
13
14
  subject.new("secret", config)
14
15
  end
@@ -17,16 +18,31 @@ describe LaunchDarkly::LDClient do
17
18
  JSON.parse(data, symbolize_names: true)
18
19
  end
19
20
  let(:user) do
20
- data = File.read(File.join("spec", "fixtures", "user.json"))
21
- JSON.parse(data, symbolize_names: true)
21
+ {
22
+ key: "user@test.com",
23
+ custom: {
24
+ groups: [ "microsoft", "google" ]
25
+ }
26
+ }
22
27
  end
23
28
  let(:numeric_key_user) do
24
- data = File.read(File.join("spec", "fixtures", "numeric_key_user.json"))
25
- JSON.parse(data, symbolize_names: true)
29
+ {
30
+ key: 33,
31
+ custom: {
32
+ groups: [ "microsoft", "google" ]
33
+ }
34
+ }
26
35
  end
27
36
  let(:sanitized_numeric_key_user) do
28
- data = File.read(File.join("spec", "fixtures", "sanitized_numeric_key_user.json"))
29
- JSON.parse(data, symbolize_names: true)
37
+ {
38
+ key: "33",
39
+ custom: {
40
+ groups: [ "microsoft", "google" ]
41
+ }
42
+ }
43
+ end
44
+ let(:user_without_key) do
45
+ { name: "Keyless Joe" }
30
46
  end
31
47
 
32
48
  def event_processor
@@ -342,6 +358,18 @@ describe LaunchDarkly::LDClient do
342
358
  expect(event_processor).to receive(:add_event).with(hash_including(user: sanitized_numeric_key_user))
343
359
  client.track("custom_event_name", numeric_key_user, nil)
344
360
  end
361
+
362
+ it "does not send an event, and logs a warning, if user is nil" do
363
+ expect(event_processor).not_to receive(:add_event)
364
+ expect(logger).to receive(:warn)
365
+ client.track("custom_event_name", nil, nil)
366
+ end
367
+
368
+ it "does not send an event, and logs a warning, if user key is nil" do
369
+ expect(event_processor).not_to receive(:add_event)
370
+ expect(logger).to receive(:warn)
371
+ client.track("custom_event_name", user_without_key, nil)
372
+ end
345
373
  end
346
374
 
347
375
  describe '#identify' do
@@ -354,6 +382,18 @@ describe LaunchDarkly::LDClient do
354
382
  expect(event_processor).to receive(:add_event).with(hash_including(user: sanitized_numeric_key_user))
355
383
  client.identify(numeric_key_user)
356
384
  end
385
+
386
+ it "does not send an event, and logs a warning, if user is nil" do
387
+ expect(event_processor).not_to receive(:add_event)
388
+ expect(logger).to receive(:warn)
389
+ client.identify(nil)
390
+ end
391
+
392
+ it "does not send an event, and logs a warning, if user key is nil" do
393
+ expect(event_processor).not_to receive(:add_event)
394
+ expect(logger).to receive(:warn)
395
+ client.identify(user_without_key)
396
+ end
357
397
  end
358
398
 
359
399
  describe 'with send_events: false' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldclient-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.3
4
+ version: 5.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-14 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb
@@ -235,6 +235,8 @@ extensions:
235
235
  extra_rdoc_files: []
236
236
  files:
237
237
  - ".circleci/config.yml"
238
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
239
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
238
240
  - ".gitignore"
239
241
  - ".hound.yml"
240
242
  - ".rspec"
@@ -297,8 +299,6 @@ files:
297
299
  - spec/file_data_source_spec.rb
298
300
  - spec/fixtures/feature.json
299
301
  - spec/fixtures/feature1.json
300
- - spec/fixtures/numeric_key_user.json
301
- - spec/fixtures/sanitized_numeric_key_user.json
302
302
  - spec/fixtures/user.json
303
303
  - spec/flags_state_spec.rb
304
304
  - spec/http_util.rb
@@ -353,8 +353,6 @@ test_files:
353
353
  - spec/file_data_source_spec.rb
354
354
  - spec/fixtures/feature.json
355
355
  - spec/fixtures/feature1.json
356
- - spec/fixtures/numeric_key_user.json
357
- - spec/fixtures/sanitized_numeric_key_user.json
358
356
  - spec/fixtures/user.json
359
357
  - spec/flags_state_spec.rb
360
358
  - spec/http_util.rb
@@ -1,9 +0,0 @@
1
- {
2
- "key": 33,
3
- "custom":{
4
- "groups":[
5
- "microsoft",
6
- "google"
7
- ]
8
- }
9
- }
@@ -1,9 +0,0 @@
1
- {
2
- "key": "33",
3
- "custom":{
4
- "groups":[
5
- "microsoft",
6
- "google"
7
- ]
8
- }
9
- }