keen 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -113,6 +113,7 @@ Running queries requires that `KEEN_READ_KEY` is set.
113
113
  Here are some examples of querying with keen-gem. Let's assume you've added some events to the "purchases" collection.
114
114
 
115
115
  ```ruby
116
+ # Various analysis types
116
117
  Keen.count("purchases") # => 100
117
118
  Keen.sum("purchases", :target_property => "price") # => 10000
118
119
  Keen.minimum("purchases", :target_property => "price") # => 20
@@ -120,23 +121,35 @@ Keen.maximum("purchases", :target_property => "price") # => 100
120
121
  Keen.average("purchases", :target_property => "price") # => 60
121
122
  Keen.median("purchases", :target_property => "price") # => 60
122
123
  Keen.percentile("purchases", :target_property => "price", :percentile => 90) # => 100
124
+ Keen.count_unique("purchases", :target_property => "username") # => 3
125
+ Keen.select_unique("purchases", :target_property => "username") # => ["Bob", "Linda", "Travis"]
123
126
 
127
+ # Group by's and filters
124
128
  Keen.sum("purchases", :target_property => "price", :group_by => "item.id") # => [{ "item.id": 123, "result": 240 }]
125
129
  Keen.count("purchases", :timeframe => "today", :filters => [{
126
130
  "property_name" => "referred_by",
127
131
  "operator" => "eq",
128
132
  "property_value" => "harry"
129
133
  }]) # => 2
134
+
135
+ # Relative timeframes
136
+ Keen.count("purchases", :timeframe => "today") # => 10
130
137
 
131
- Keen.count_unique("purchases", :target_property => "username") # => 3
132
- Keen.select_unique("purchases", :target_property => "username") # => ["Bob", "Linda", "Travis"]
138
+ # Absolute timeframes
139
+ Keen.count("purchases", :timeframe => {
140
+ :start => "2015-01-01T00:00:00Z",
141
+ :end => "2015-31-01T00:00:00Z"
142
+ }) # => 5
133
143
 
144
+ # Extractions
134
145
  Keen.extraction("purchases") # => [{ "keen" => { "timestamp" => "2014-01-01T00:00:00Z" }, "price" => 20 }]
135
146
 
147
+ # Funnels
136
148
  Keen.funnel(:steps => [{
137
149
  :actor_property => "username", :event_collection => "purchases" }, {
138
150
  :actor_property => "username", :event_collection => "referrals" }]) # => [20, 15]
139
151
 
152
+ # Multi-analysis
140
153
  Keen.multi_analysis("purchases", analyses: {
141
154
  :gross => { :analysis_type => "sum", :target_property => "price" },
142
155
  :customers => { :analysis_type => "count_unique", :target_property => "username" } },
@@ -270,7 +283,6 @@ Keen.project_id = 'xxxxxxxxxxxxxxx'
270
283
  Keen.write_key = 'yyyyyyyyyyyyyyy'
271
284
  Keen.read_key = 'zzzzzzzzzzzzzzz'
272
285
  Keen.master_key = 'aaaaaaaaaaaaaaa'
273
- Keen.read_timeoout = 60
274
286
  ```
275
287
 
276
288
  You can also configure unique client instances as follows:
@@ -279,8 +291,7 @@ You can also configure unique client instances as follows:
279
291
  keen = Keen::Client.new(:project_id => 'xxxxxxxxxxxxxxx',
280
292
  :write_key => 'yyyyyyyyyyyyyyy',
281
293
  :read_key => 'zzzzzzzzzzzzzzz',
282
- :master_key => 'aaaaaaaaaaaaaaa',
283
- :read_timeout => 60)
294
+ :master_key => 'aaaaaaaaaaaaaaa')
284
295
  ```
285
296
 
286
297
  #### em-synchrony
@@ -340,14 +351,17 @@ You can use the scoped key created in Ruby for API requests from any client. Sco
340
351
 
341
352
  The default `Net:HTTP` timeout is 60 seconds. That's usually enough, but if you're querying over a large collection you may need to increase it. The timeout on the API side is 300 seconds, so that's as far as you'd want to go. You can configure a read timeout (in seconds) by setting a `KEEN_READ_TIMEOUT` environment variable, or by passing in a `read_timeout` option to the client constructor as follows:
342
353
 
343
- ```
354
+ ``` ruby
344
355
  keen = Keen::Client.new(:read_timeout => 300)
345
356
  ```
346
357
 
347
358
  ##### HTTP Proxy
348
359
 
349
- You can set the `KEEN_PROXY_TYPE` and `KEEN_PROXY_URL` environment variables to enable HTTP proxying. `KEEN_PROXY_TYPE` should most likely be set to `socks5`. You can also configure this on client instances by passing in `proxy_type` and `proxy_url` keys.
360
+ You can set the `KEEN_PROXY_TYPE` and `KEEN_PROXY_URL` environment variables to enable HTTP proxying. `KEEN_PROXY_TYPE` should be set to `socks5`. You can also configure this on client instances by passing in `proxy_type` and `proxy_url` keys.
350
361
 
362
+ ``` ruby
363
+ keen = Keen::Client.new(:proxy_type => 'socks5', :proxy_url => 'http://localhost:8888')
364
+ ```
351
365
 
352
366
  ### Troubleshooting
353
367
 
@@ -364,6 +378,9 @@ EventMachine itself won't do this because it runs in a different thread. Here's
364
378
 
365
379
  ### Changelog
366
380
 
381
+ ##### 0.8.9
382
+ + Fix proxy support for sync client. Thanks [@nvieirafelipe](https://github.com/nvieirafelipe)!
383
+
367
384
  ##### 0.8.8
368
385
  + Add support for a configurable read timeout
369
386
 
data/lib/keen/http.rb CHANGED
@@ -22,7 +22,7 @@ module Keen
22
22
  end
23
23
 
24
24
  def proxy_arguments_for(uri)
25
- proxy_uri = URI.parse(proxy_url)
25
+ proxy_uri = URI.parse(uri)
26
26
  [proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password]
27
27
  end
28
28
 
@@ -27,9 +27,8 @@ module Keen
27
27
  def encrypt!
28
28
  json_str = MultiJson.dump(self.data)
29
29
  padded_api_key = pad(self.api_key)
30
- padded_data = pad(json_str)
31
30
  encrypted, iv = aes256_encrypt(padded_api_key, json_str)
32
31
  hexlify(iv) + hexlify(encrypted)
33
32
  end
34
33
  end
35
- end
34
+ end
data/lib/keen/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Keen
2
- VERSION = "0.8.8"
2
+ VERSION = "0.8.9"
3
3
  end
@@ -71,6 +71,22 @@ describe Keen::Client::PublishingMethods do
71
71
  ).publish(collection, event_properties)
72
72
  }.to raise_error(Keen::ConfigurationError, "Keen IO Exception: Write Key must be set for this operation")
73
73
  end
74
+
75
+ context "when using proxy" do
76
+ let(:client) do
77
+ Keen::Client.new(:project_id => project_id,
78
+ :write_key => write_key,
79
+ :api_url => api_url,
80
+ :proxy_url => "http://localhost:8888",
81
+ :proxy_type => "socks5")
82
+ end
83
+
84
+ it "should return the proper response" do
85
+ api_response = { "created" => true }
86
+ stub_keen_post(api_event_collection_resource_url(api_url, collection), 201, api_response)
87
+ client.publish(collection, event_properties).should == api_response
88
+ end
89
+ end
74
90
  end
75
91
 
76
92
  describe "publish_batch" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-12-19 00:00:00.000000000 Z
14
+ date: 2015-02-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: multi_json