leanplum_api 1.3.5 → 1.3.6

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: e3ada1da3173ffd60da9b2abdddbf4901d20d8cd
4
- data.tar.gz: 56ca6681108d38d0d91aed19701624db0faae812
3
+ metadata.gz: ce4fe4f8ab0087d81620500bfbb5b8772fc5fce0
4
+ data.tar.gz: e9b7b9754428c7e7271dc02ad6902400d1ad06f8
5
5
  SHA512:
6
- metadata.gz: f7f0436608323f894b38932da9dd1cd2ebab1aa5f992267fc0c01f871d48e6bdfed8800317dd255907ec6858a18711118e19de9820165d8cc133ff2663030651
7
- data.tar.gz: f35e6b7a620fb5f4136f3914381f46abcff6931ebda1a5dbeb5efd2a9fcd072c80bde63b2c7a00135413b803af5fc472b006faa20259d8baab7b7f5b29bc9929
6
+ metadata.gz: db56dbc6b349e76245c5ff6f02442088dd4d0f0e84b4018bbb49e05921a6590d3e8a3d3a75b88d2b33f2091f6918552716e860c411328350f3340f01122e6d99
7
+ data.tar.gz: 4287a74432cce7921da7e0a8c601ad649d855aab79fcb89bdbfe78f93cb34fcbbeec5b981f1d4e0e58eb1eac74e42ec796096e369c3911fa5eb7da01ed96e68f
data/README.md CHANGED
@@ -14,14 +14,14 @@ required_ruby_version is set to 1.9 but this code has only been tested with Ruby
14
14
 
15
15
  ## Configuration
16
16
 
17
- You need to obtain (at a minimum) the PRODUCTION and APP_ID from Leanplum. You may also want to configure the DATA_EXPORT_KEY, CONTENT_READ_ONLY_KEY, and DEVELOPMENT_KEY if you plan on calling methods that require those keys. Then you can setup the gem for use in your application like so:
17
+ You need to obtain (at a minimum) the `PRODUCTION_KEY` and `APP_ID` from Leanplum. You may also want to configure the `DATA_EXPORT_KEY`, `CONTENT_READ_ONLY_KEY`, and `DEVELOPMENT_KEY` if you plan on calling methods that require those keys. Then you can setup the gem for use in your application like so:
18
18
 
19
19
  ```ruby
20
20
  require 'leanplum_api'
21
21
 
22
22
  LeanplumApi.configure do |config|
23
- config.production_key = 'MY_CLIENT_KEY'
24
23
  config.app_id = 'MY_APP_ID'
24
+ config.production_key = 'MY_CLIENT_KEY'
25
25
  config.data_export_key = 'MY_DATA_KEY' # Optional; necessary only if you want to call data export methods.
26
26
  config.content_read_only_key = 'MY_CONTENT_KEY' # Optional; necessary for retrieving AB test info
27
27
  config.development_key = 'MY_CONTENT_KEY' # Optional; needed for resetting anomalous events
@@ -90,28 +90,9 @@ job_id = api.export_data(start_time, end_time)
90
90
  response = wait_for_job(job_id)
91
91
  ```
92
92
 
93
- ## Logging
94
-
95
- When you instantiate a ```LeanplumApi::API``` object, you can pass a ```Logger``` object to redirect the logging as you see fit.
96
-
97
- ```ruby
98
- api = LeanplumApi::API.new(logger: Logger.new('/path/to/my/log_file.log))
99
- ```
100
-
101
- Alternatively, you can configure a log_path in the configure block.
102
- ```ruby
103
- LeanplumApi.configure do |config|
104
- config.log_path = '/path/to/my/logs'
105
- end
106
- ```
107
-
108
- And logs will be sent to ```/path/to/my/logs/{PID}_leanplum_{timestamp}.log```
109
-
110
- The default log_path is ```log/```
111
-
112
- ## Tests
93
+ ## Specs
113
94
 
114
- To run tests, you must set the LEANPLUM_PRODUCTION_KEY, LEANPLUM_APP_ID, LEANPLUM_CONTENT_READ_ONLY_KEY, LEANPLUM_DEVELOPMENT_KEY, and LEANPLUM_DATA_EXPORT_KEY environment variables (preferably to some development only keys) to something and then run rspec.
95
+ To run specs, you must set the LEANPLUM_PRODUCTION_KEY, LEANPLUM_APP_ID, LEANPLUM_CONTENT_READ_ONLY_KEY, LEANPLUM_DEVELOPMENT_KEY, and LEANPLUM_DATA_EXPORT_KEY environment variables (preferably to some development only keys) to something and then run rspec.
115
96
  Because of the nature of VCR/Webmock, you can set them to anything (including invalid keys) as long as you are not changing anything substantive or writing new specs. If you want to make substantive changes/add new specs, VCR will need to be able to generate fixture data so you will need to use a real set of Leanplum keys.
116
97
 
117
98
  > BE AWARE THAT IF YOU WRITE A NEW SPEC OR DELETE A VCR FILE, IT'S POSSIBLE THAT REAL DATA WILL BE WRITTEN TO THE LEANPLUM_APP_ID YOU CONFIGURE! Certainly a real request will be made to rebuild the VCR file, and while specs run with ```devMode=true```, it's usually a good idea to create a fake app for testing/running specs against.
@@ -34,10 +34,19 @@ module LeanplumApi
34
34
  user_ids_to_reset = []
35
35
  response.body['response'].each_with_index do |indicator, i|
36
36
  if indicator['warning'] && indicator['warning']['message'] =~ /Anomaly detected/i
37
- user_ids_to_reset << (events + user_attributes)[i][:user_id]
37
+ # Leanplum does not return their warnings in order!!! So we just have to reset everyone who had any events.
38
+ # This is what the code should be:
39
+ # user_ids_to_reset << request_data[i]['userId']
40
+
41
+ # This is what it has to be:
42
+ user_ids_to_reset = events.map { |e| e[:user_id] }
38
43
  end
39
44
  end
40
- reset_anomalous_users(user_ids_to_reset)
45
+
46
+ unless user_ids_to_reset.empty?
47
+ LeanplumApi.configuration.logger.info("Resetting anomalous user ids: #{user_ids_to_reset}")
48
+ reset_anomalous_users(user_ids_to_reset)
49
+ end
41
50
  end
42
51
  end
43
52
 
@@ -140,7 +149,7 @@ module LeanplumApi
140
149
  # For some reason this API feature requires the developer key
141
150
  def reset_anomalous_users(user_ids)
142
151
  user_ids = Array.wrap(user_ids)
143
- request_data = user_ids.map { |user_id| { 'action' => 'setUserAttributes', 'resetAnomalies' => true, 'userId' => user_id } }
152
+ request_data = user_ids.map { |user_id| { action: 'setUserAttributes', resetAnomalies: true, userId: user_id } }
144
153
  development_connection.post(request_data)
145
154
  end
146
155
 
@@ -1,3 +1,3 @@
1
1
  module LeanplumApi
2
- VERSION = '1.3.5'
2
+ VERSION = '1.3.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leanplum_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lumos Labs, Inc.