keen 0.9.5 → 0.9.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: a1699510fc2d24980d980c0fc72cd2a8b95db715
4
- data.tar.gz: a50d16fe6edff311e4482217a96a89f812b81988
3
+ metadata.gz: 64f0b30d33e55ce7197790586a4bdb00ad08390a
4
+ data.tar.gz: 6747562055bfacc541ed9ea647673579d8f78427
5
5
  SHA512:
6
- metadata.gz: 8d4e6b05301f89eaf477bc95f4b9297ac22ca96706e3133458cccdff0bd2a2a0d0a6f6c377273e5358bee1924a0a52376068e8d34f4fcc875ec20d959a816ec3
7
- data.tar.gz: eea17f8068313eefcb15f2c23460f23fccf212e1464e12050ee18f2069980d344581cb39228c38838a02f8363ab6bc0988b62b39cb488e019f9a70b1a092d5f5
6
+ metadata.gz: eaccbc7ea6b950f3582c06f237c7c49d8dea86bd314857b7842ddaf16b19cc22a8220ebe0e06056ae50cd2bb255598d2afec92f9b890073739e731b33683663e
7
+ data.tar.gz: 35ae078dbc0234070ecb08c41a4d5328e36ef4b652c4c0270983db1ab927405540a854c02b385f33e92aa2318f68f5fc18d1ec0fe133462373ca403c5395c0ea
data/README.md CHANGED
@@ -25,15 +25,15 @@ keen is tested with Ruby 1.9.3 + and on:
25
25
  ### Usage
26
26
 
27
27
  Before making any API calls, you must supply keen-gem with a Project ID and one or more authentication keys.
28
- (If you need a Keen IO account, [sign up here](https://keen.io/signup?s=gh-gem) - it's free.)
28
+ (If you need a Keen IO account, [sign up here](https://keen.io/signup?s=gh-gem) - it's free.)
29
29
 
30
- Setting a write key is required for publishing events. Setting a read key is required for running queries.
30
+ Setting a write key is required for publishing events. Setting a read key is required for running queries.
31
31
  Setting a master key is required for performing deletes. You can find keys for all of your projects
32
32
  on [keen.io](https://keen.io?s=gh-gem).
33
33
 
34
- The recommended way to set keys is via the environment. The keys you can set are
34
+ The recommended way to set keys is via the environment. The keys you can set are
35
35
  `KEEN_PROJECT_ID`, `KEEN_WRITE_KEY`, `KEEN_READ_KEY` and `KEEN_MASTER_KEY`.
36
- You only need to specify the keys that correspond to the API calls you'll be performing.
36
+ You only need to specify the keys that correspond to the API calls you'll be performing.
37
37
  If you're using [foreman](http://ddollar.github.com/foreman/), add this to your `.env` file:
38
38
 
39
39
  KEEN_PROJECT_ID=aaaaaaaaaaaaaaa
@@ -57,8 +57,8 @@ Publishing events requires that `KEEN_WRITE_KEY` is set. Publish an event like t
57
57
  Keen.publish(:sign_ups, { :username => "lloyd", :referred_by => "harry" })
58
58
  ```
59
59
 
60
- This will publish an event to the `sign_ups` collection with the `username` and `referred_by` properties set.
61
- The event properties can be any valid Ruby hash. Nested properties are allowed. Lists of objects are also allowed, but not recommended because they can be difficult to query over. See alternatives to lists of objects [here](http://stackoverflow.com/questions/24620330/nested-json-objects-in-keen-io). You can learn more about data modeling with Keen IO with the [Data Modeling Guide](https://keen.io/docs/event-data-modeling/event-data-intro/?s=gh-gem).
60
+ This will publish an event to the `sign_ups` collection with the `username` and `referred_by` properties set.
61
+ The event properties can be any valid Ruby hash. Nested properties are allowed. Lists of objects are also allowed, but not recommended because they can be difficult to query over. See alternatives to lists of objects [here](http://stackoverflow.com/questions/24620330/nested-json-objects-in-keen-io). You can learn more about data modeling with Keen IO with the [Data Modeling Guide](https://keen.io/docs/event-data-modeling/event-data-intro/?s=gh-gem).
62
62
 
63
63
  Protip: Marshalling gems like [Blockhead](https://github.com/vinniefranco/blockhead) make converting structs or objects to hashes easier.
64
64
 
@@ -131,21 +131,21 @@ Keen.count("purchases", :timeframe => "today", :filters => [{
131
131
  "operator" => "eq",
132
132
  "property_value" => "harry"
133
133
  }]) # => 2
134
-
134
+
135
135
  # Relative timeframes
136
136
  Keen.count("purchases", :timeframe => "today") # => 10
137
137
 
138
138
  # Absolute timeframes
139
- Keen.count("purchases", :timeframe => {
140
- :start => "2015-01-01T00:00:00Z",
141
- :end => "2015-31-01T00:00:00Z"
139
+ Keen.count("purchases", :timeframe => {
140
+ :start => "2015-01-01T00:00:00Z",
141
+ :end => "2015-31-01T00:00:00Z"
142
142
  }) # => 5
143
143
 
144
144
  # Extractions
145
145
  Keen.extraction("purchases", :timeframe => "today") # => [{ "keen" => { "timestamp" => "2014-01-01T00:00:00Z" }, "price" => 20 }]
146
146
 
147
147
  # Funnels
148
- Keen.funnel(:steps => [{
148
+ Keen.funnel(:steps => [{
149
149
  :actor_property => "username", :event_collection => "purchases", :timeframe => "yesterday" }, {
150
150
  :actor_property => "username", :event_collection => "referrals", :timeframe => "yesterday" }]) # => [20, 15]
151
151
 
@@ -259,7 +259,7 @@ Keen stores all date and time information in UTC!
259
259
  Keen.publish(:sign_ups, {
260
260
  :keen => { :timestamp => "2012-12-14T20:24:01.123000+00:00" },
261
261
  :username => "lloyd",
262
- :referred_by => "harry"
262
+ :referred_by => "harry"
263
263
  })
264
264
  ```
265
265
 
@@ -283,7 +283,7 @@ Keen.publish_batch(
283
283
  This call would publish 2 `signups` events and 2 `purchases` events - all in just one API call.
284
284
  Batch publishing is ideal for loading historical events into Keen IO.
285
285
 
286
- #### Asynchronous batch publishing
286
+ #### Asynchronous batch publishing
287
287
 
288
288
  Ensuring the above guidance is followed for asynchronous publishing, batch publishing logic can used asynchronously with `publish_batch_async`:
289
289
 
@@ -393,7 +393,7 @@ keen = Keen::Client.new(:proxy_type => 'socks5', :proxy_url => 'http://localhost
393
393
 
394
394
  ##### EventMachine
395
395
 
396
- If you run into `Keen::Error: Keen IO Exception: An EventMachine loop must be running to use publish_async calls` or
396
+ If you run into `Keen::Error: Keen IO Exception: An EventMachine loop must be running to use publish_async calls` or
397
397
  `Uncaught RuntimeError: eventmachine not initialized: evma_set_pending_connect_timeout`, this means that the EventMachine
398
398
  loop has died. This can happen for a variety of reasons, and every app is different. [Issue #22](https://github.com/keenlabs/keen-gem/issues/22) shows how to add some extra protection to avoid this situation.
399
399
 
@@ -412,6 +412,9 @@ If you want some bot protection, check out the [Voight-Kampff](https://github.co
412
412
 
413
413
  ### Changelog
414
414
 
415
+ ##### 0.9.6
416
+ + Updated behavior of saved queries to allow fetching results using the READ KEY as opposed to requiring the MASTER KEY, making the gem consistent with https://keen.io/docs/api/#getting-saved-query-results
417
+
415
418
  ##### 0.9.5
416
419
  + Fix bug with scoped key generation not working with newer Keen projects.
417
420
 
@@ -518,7 +521,7 @@ server-side querying processes require a Read key that should not be made public
518
521
  ### Questions & Support
519
522
 
520
523
  For questions, bugs, or suggestions about this gem:
521
- [File a Github Issue](https://github.com/keenlabs/keen-gem/issues).
524
+ [File a Github Issue](https://github.com/keenlabs/keen-gem/issues).
522
525
 
523
526
  For other Keen-IO related technical questions:
524
527
  ['keen-io' on Stack Overflow](http://stackoverflow.com/questions/tagged/keen-io)
@@ -6,15 +6,18 @@ class SavedQueries
6
6
  end
7
7
 
8
8
  def all
9
- process_response(saved_query_response)
9
+ process_response(saved_query_response(client.master_key))
10
10
  end
11
11
 
12
12
  def get(saved_query_name, results = false)
13
13
  saved_query_path = "/#{saved_query_name}"
14
+ api_key = client.master_key
14
15
  if results
15
16
  saved_query_path += "/result"
17
+ # The results path should use the READ KEY
18
+ api_key = client.read_key
16
19
  end
17
- response = saved_query_response(saved_query_path)
20
+ response = saved_query_response(api_key, saved_query_path)
18
21
  response_body = JSON.parse(response.body, symbolize_names: true)
19
22
  process_response(response)
20
23
  end
@@ -41,10 +44,10 @@ class SavedQueries
41
44
 
42
45
  attr_reader :client
43
46
 
44
- def saved_query_response(path = "")
47
+ def saved_query_response(api_key, path = "")
45
48
  Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout).get(
46
49
  path: saved_query_base_url + path,
47
- headers: api_headers(client.master_key, "sync")
50
+ headers: api_headers(api_key, "sync")
48
51
  )
49
52
  end
50
53
 
data/lib/keen/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Keen
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.6"
3
3
  end
@@ -3,7 +3,8 @@ require File.expand_path("../spec_helper", __FILE__)
3
3
  describe "Saved Queries" do
4
4
  let(:project_id) { ENV["KEEN_PROJECT_ID"] }
5
5
  let(:master_key) { ENV["KEEN_MASTER_KEY"] }
6
- let(:client) { Keen::Client.new(project_id: project_id, master_key: master_key) }
6
+ let(:read_key) { ENV["KEEN_READ_KEY"] }
7
+ let(:client) { Keen::Client.new(project_id: project_id, master_key: master_key, read_key: read_key) }
7
8
 
8
9
  describe "#all" do
9
10
  it "gets all saved_queries" 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.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kleissner
@@ -9,132 +9,132 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-13 00:00:00.000000000 Z
12
+ date: 2016-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: addressable
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
34
  version: 2.3.5
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  version: 2.3.5
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: guard
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: guard-rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rb-inotify
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ">="
81
+ - - '>='
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rb-fsevent
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - '>='
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rb-fchange
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ">="
102
+ - - '>='
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: ruby_gntp
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rb-readline
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ">="
130
+ - - '>='
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - '>='
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  description: Send events and build analytics features into your Ruby applications.
@@ -143,9 +143,9 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - ".gitignore"
147
- - ".rspec"
148
- - ".travis.yml"
146
+ - .gitignore
147
+ - .rspec
148
+ - .travis.yml
149
149
  - Gemfile
150
150
  - Guardfile
151
151
  - LICENSE
@@ -189,17 +189,17 @@ require_paths:
189
189
  - lib
190
190
  required_ruby_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - '>='
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - ">="
197
+ - - '>='
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.4.5
202
+ rubygems_version: 2.0.14.1
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Keen IO API Client