leanplum_api 2.0.1 → 3.0.1

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: 7b8d4f6eb38f52bcc546f280eedf54ae413f6029
4
- data.tar.gz: 023e78d43a6bd80fb69eb4a225a4fc59a14a72db
3
+ metadata.gz: 2e94814a101ee266130f5484232809cd1543d641
4
+ data.tar.gz: 1f6bd9fefa701bad19d839fbc42dcc0833a61d6a
5
5
  SHA512:
6
- metadata.gz: 93b7f8cd1ce616bcbe16a0c5045363e8defad9a23c746333b91a7bac2bf30dfe1c09b023835e689d01aac07310b9d391eb540ba63853c03cc8b92bcc27b74b5c
7
- data.tar.gz: 54648ce19ffa56ff6f4377100181e6347228d1def62dd0af22ec3e4734c27be1385dc0e14848571f527b149dbb691d86a6b0311fa3a71cb582959702edcc1d1c
6
+ metadata.gz: acbaab2cf26e530ab7fc1f48a5021f6f1732c4b75255448e2f28f079fe6b70a1233f588211f6dd11b82402eb99d625297abc0c96ba3b2e7bfa1aad25891855e2
7
+ data.tar.gz: 1f72ae8dcd7e107af18433ab762447c0df4f96cb763cc0aefd5276efd4a29402216b3cda8b7b68a3b8b2ed216c9e6ebfd616bbe9d9658e1bbdaa46e6b4e60733
data/README.md CHANGED
@@ -10,7 +10,7 @@ The gem uses the ```multi``` method with a POST for all event tracking and user
10
10
 
11
11
  Tested with Leanplum API version 1.0.6.
12
12
 
13
- required_ruby_version is set to 1.9 but this code has only been tested with Ruby 2.1.5!
13
+ `required_ruby_version` is set to 1.9 but this code has only been tested with Ruby 2.1.5 and up!
14
14
 
15
15
  ## Configuration
16
16
 
@@ -125,4 +125,14 @@ export LEANPLUM_API_DEBUG=true
125
125
  bundle exec whatever
126
126
  ```
127
127
 
128
+ Alternatively you can configure the same sort of output in the gem config block:
129
+
130
+ ```ruby
131
+ LeanplumApi.configure do |config|
132
+ config.api_debug = true
133
+ end
134
+ ```
135
+
136
+ ### Developer Mode
137
+
128
138
  You can also configure "developer mode". This will use the `devMode=true` parameter on some requests, which seems to sends them to a separate queue which might not count towards Leanplum's usage billing.
@@ -116,7 +116,18 @@ module LeanplumApi
116
116
  end
117
117
 
118
118
  def user_attributes(user_id)
119
- export_user(user_id)['userAttributes']
119
+ export_user(user_id)['userAttributes'].inject({}) do |attrs, (k, v)|
120
+ # Leanplum doesn't use true JSON for booleans...
121
+ if v == 'True'
122
+ attrs[k] = true
123
+ elsif v == 'False'
124
+ attrs[k] = false
125
+ else
126
+ attrs[k] = v
127
+ end
128
+
129
+ attrs
130
+ end
120
131
  end
121
132
 
122
133
  def user_events(user_id)
@@ -205,7 +216,7 @@ module LeanplumApi
205
216
  def build_event_attributes_hash(event_hash, options = {})
206
217
  event_hash = HashWithIndifferentAccess.new(event_hash)
207
218
  event_name = event_hash.delete(:event)
208
- fail "Event name or timestamp not provided in #{event_hash}" unless event_name
219
+ fail ":event key not present in #{event_hash}" unless event_name
209
220
 
210
221
  event = { action: 'track', event: event_name }.merge(extract_user_id_or_device_id_hash!(event_hash))
211
222
  event.merge!(time: event_hash.delete(:time).strftime('%s')) if event_hash[:time]
@@ -23,9 +23,9 @@ module LeanplumApi
23
23
  attr_accessor :development_key
24
24
 
25
25
  # Optional
26
+ attr_accessor :api_debug
26
27
  attr_accessor :api_version
27
28
  attr_accessor :developer_mode
28
- attr_accessor :log_path
29
29
  attr_accessor :logger
30
30
  attr_accessor :timeout_seconds
31
31
 
@@ -41,9 +41,7 @@ module LeanplumApi
41
41
  @developer_mode = false
42
42
  @timeout_seconds = 600
43
43
  @logger = LeanplumApi::Logger.new(STDOUT)
44
-
45
- # Deprecated
46
- @log_path = 'log'
44
+ @api_debug = ENV['LEANPLUM_API_DEBUG'].to_s =~ /^(true|t|yes|y|1)$/i
47
45
  end
48
46
  end
49
47
  end
@@ -43,17 +43,13 @@ module LeanplumApi::Connection
43
43
  connection.request :leanplum_response_validation
44
44
  connection.request :json
45
45
 
46
- connection.response :logger, @logger, bodies: true if api_debug?
46
+ connection.response :logger, @logger, bodies: true if LeanplumApi.configuration.api_debug
47
47
  connection.response :json, :content_type => /\bjson$/
48
48
 
49
49
  connection.adapter Faraday.default_adapter
50
50
  end
51
51
  end
52
52
 
53
- def api_debug?
54
- ENV['LEANPLUM_API_DEBUG'].to_s =~ /^(true|1)$/i
55
- end
56
-
57
53
  def authed_multi_param_string
58
54
  params = authentication_params.merge(action: 'multi', time: Time.now.utc.strftime('%s'))
59
55
  params.merge!(devMode: true) if LeanplumApi.configuration.developer_mode
@@ -1,3 +1,3 @@
1
1
  module LeanplumApi
2
- VERSION = '2.0.1'
2
+ VERSION = '3.0.1'
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -10,7 +10,8 @@ describe LeanplumApi::API do
10
10
  last_name: 'Jones',
11
11
  gender: 'm',
12
12
  email: 'still_tippin@test.com',
13
- create_date: '2010-01-01'.to_date
13
+ create_date: '2010-01-01'.to_date,
14
+ is_tipping: true
14
15
  }]
15
16
  end
16
17
 
@@ -24,7 +25,8 @@ describe LeanplumApi::API do
24
25
  last_name: 'Jones',
25
26
  gender: 'm',
26
27
  email: 'still_tippin@test.com',
27
- create_date: '2010-01-01'
28
+ create_date: '2010-01-01',
29
+ is_tipping: true
28
30
  )
29
31
  })
30
32
  end
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
11
+ - Faraday v0.10.0
12
12
  Accept-Encoding:
13
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
14
  Accept:
@@ -22,19 +22,21 @@ http_interactions:
22
22
  - "*"
23
23
  Content-Type:
24
24
  - application/json
25
+ X-Cloud-Trace-Context:
26
+ - b7ed8a2d93f600276bf6f09eddff4c8c
25
27
  Date:
26
- - Fri, 01 Jul 2016 14:47:49 GMT
28
+ - Tue, 15 Nov 2016 10:32:36 GMT
27
29
  Server:
28
30
  - Google Frontend
31
+ Content-Length:
32
+ - '303'
33
+ Expires:
34
+ - Tue, 15 Nov 2016 10:32:36 GMT
29
35
  Cache-Control:
30
36
  - private
31
- Alt-Svc:
32
- - quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"
33
- Transfer-Encoding:
34
- - chunked
35
37
  body:
36
38
  encoding: UTF-8
37
- string: '{"response":[{"created":1.43935302887E9,"events":{"purchase":{"count":11}},"lastActive":1.446709787966E9,"states":{},"success":true,"userAttributes":{"first_name":"Mike","create_date":"2010-01-01","email":"still_tippin@test.com","last_name":"Jones","gender":"m"}}]}'
38
- http_version:
39
+ string: '{"response":[{"totalSessions":0,"created":1.43935302887E9,"events":{"purchase":{"count":24}},"lastActive":1.446709787966E9,"states":{},"success":true,"userAttributes":{"first_name":"Mike","create_date":"2010-01-01","email":"still_tippin@test.com","last_name":"Jones","is_tipping":"True","gender":"m"}}]}'
40
+ http_version:
39
41
  recorded_at: Wed, 12 Aug 2015 04:00:00 GMT
40
42
  recorded_with: VCR 3.0.3
@@ -5,10 +5,10 @@ http_interactions:
5
5
  uri: https://www.leanplum.com/api?action=multi&apiVersion=1.0.6&appId=<LEANPLUM_APP_ID>&clientKey=<LEANPLUM_PRODUCTION_KEY>&devMode=false&time=1439352000
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"data":[{"userId":123456,"action":"setUserAttributes","userAttributes":{"first_name":"Mike","last_name":"Jones","gender":"m","email":"still_tippin@test.com","create_date":"2010-01-01"}}]}'
8
+ string: '{"data":[{"userId":123456,"action":"setUserAttributes","userAttributes":{"first_name":"Mike","last_name":"Jones","gender":"m","email":"still_tippin@test.com","create_date":"2010-01-01","is_tipping":true}}]}'
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
11
+ - Faraday v0.10.0
12
12
  Content-Type:
13
13
  - application/json
14
14
  Accept-Encoding:
@@ -24,20 +24,22 @@ http_interactions:
24
24
  - "*"
25
25
  Content-Type:
26
26
  - application/json
27
+ X-Cloud-Trace-Context:
28
+ - be84cbe23b33980fe7159ca706386efb
27
29
  Date:
28
- - Fri, 01 Jul 2016 14:47:49 GMT
30
+ - Tue, 15 Nov 2016 10:28:11 GMT
29
31
  Server:
30
32
  - Google Frontend
33
+ Content-Length:
34
+ - '122'
35
+ Expires:
36
+ - Tue, 15 Nov 2016 10:28:11 GMT
31
37
  Cache-Control:
32
38
  - private
33
- Alt-Svc:
34
- - quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"
35
- Transfer-Encoding:
36
- - chunked
37
39
  body:
38
40
  encoding: UTF-8
39
41
  string: '{"response":[{"success":true,"warning":{"message":"Anomaly detected:
40
42
  time skew. User will be excluded from analytics."}}]}'
41
- http_version:
43
+ http_version:
42
44
  recorded_at: Wed, 12 Aug 2015 04:00:00 GMT
43
45
  recorded_with: VCR 3.0.3
@@ -5,11 +5,11 @@ http_interactions:
5
5
  uri: https://www.leanplum.com/api?action=multi&apiVersion=1.0.6&appId=<LEANPLUM_APP_ID>&clientKey=<LEANPLUM_PRODUCTION_KEY>&devMode=false&time=1439352000
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"data":[{"userId":123456,"action":"setUserAttributes","userAttributes":{"first_name":"Mike","last_name":"Jones","gender":"m","email":"still_tippin@test.com","create_date":"2010-01-01"}},{"action":"track","event":"purchase","userId":123456,"time":"1439352000","params":{"some_timestamp":"2015-05-01
8
+ string: '{"data":[{"userId":123456,"action":"setUserAttributes","userAttributes":{"first_name":"Mike","last_name":"Jones","gender":"m","email":"still_tippin@test.com","create_date":"2010-01-01","is_tipping":true}},{"action":"track","event":"purchase","userId":123456,"time":"1439352000","params":{"some_timestamp":"2015-05-01
9
9
  01:02:03"}},{"action":"track","event":"purchase_page_view","userId":54321,"time":"1439351400"}]}'
10
10
  headers:
11
11
  User-Agent:
12
- - Faraday v0.9.2
12
+ - Faraday v0.10.0
13
13
  Content-Type:
14
14
  - application/json
15
15
  Accept-Encoding:
@@ -25,22 +25,24 @@ http_interactions:
25
25
  - "*"
26
26
  Content-Type:
27
27
  - application/json
28
+ X-Cloud-Trace-Context:
29
+ - 4a5e92e1cf1088dd41b9caa898272564
28
30
  Date:
29
- - Fri, 01 Jul 2016 14:47:51 GMT
31
+ - Tue, 15 Nov 2016 10:29:45 GMT
30
32
  Server:
31
33
  - Google Frontend
34
+ Content-Length:
35
+ - '372'
36
+ Expires:
37
+ - Tue, 15 Nov 2016 10:29:45 GMT
32
38
  Cache-Control:
33
39
  - private
34
- Alt-Svc:
35
- - quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"
36
- Transfer-Encoding:
37
- - chunked
38
40
  body:
39
41
  encoding: UTF-8
40
42
  string: '{"response":[{"success":true,"warning":{"message":"Anomaly detected:
41
43
  time skew. User will be excluded from analytics."}},{"isOffline":true,"success":true,"warning":{"message":"Anomaly
42
44
  detected: time skew. User will be excluded from analytics."}},{"isOffline":true,"success":true,"warning":{"message":"Anomaly
43
45
  detected: time skew. User will be excluded from analytics."}}]}'
44
- http_version:
46
+ http_version:
45
47
  recorded_at: Wed, 12 Aug 2015 04:00:00 GMT
46
48
  recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leanplum_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lumos Labs, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-01 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -78,20 +78,6 @@ dependencies:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0.10'
81
- - !ruby/object:Gem::Dependency
82
- name: rake
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '10.4'
88
- type: :runtime
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - "~>"
93
- - !ruby/object:Gem::Version
94
- version: '10.4'
95
81
  - !ruby/object:Gem::Dependency
96
82
  name: rspec
97
83
  requirement: !ruby/object:Gem::Requirement
@@ -158,7 +144,6 @@ files:
158
144
  - Gemfile
159
145
  - LICENSE.txt
160
146
  - README.md
161
- - Rakefile
162
147
  - lib/leanplum_api.rb
163
148
  - lib/leanplum_api/api.rb
164
149
  - lib/leanplum_api/configuration.rb
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- require 'bundler/gem_tasks'
2
-
3
- require 'rspec/core'
4
- require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new(:spec) do |spec|
6
- spec.pattern = FileList['spec/**/*_spec.rb']
7
- end
8
-
9
- task prep: %w(spec)
10
-
11
- task default: :spec