keen-cli 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +22 -17
- data/Rakefile +1 -1
- data/keen-cli.gemspec +1 -1
- data/lib/keen-cli/batch_processor.rb +11 -0
- data/lib/keen-cli/version.rb +1 -1
- data/spec/keen-cli/batch_processor_spec.rb +5 -0
- metadata +24 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 494c97428e79141428c1ed3beb39b22be64868ed
|
4
|
+
data.tar.gz: 8d205f837afd7f7edfcfbf4f775e1b69b6f89b20
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a1c4010491f5f9a88df9b8b2a5a5591afb13fc2fab504ebfaf6ef3ab6cfd3a6f5e135ab98594fa1496b8e53a4cf065f1611fee5e40afe59b5ed44389d44fa792
|
7
|
+
data.tar.gz: 6720ca7a9c805084ff98096eac81153425792a7886b886bb5bc7f626e04c6e8561c9797e8de9e3a9f7e6021c51ee32792eb7700c47540388c070a89e27686586
|
data/README.md
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
|
5
5
|
A command line interface for the Keen IO analytics API.
|
6
6
|
|
7
|
+
### Community-Supported SDK
|
8
|
+
This is an _unofficial_ community supported SDK. If you find any issues or have a request please post an [issue](https://github.com/keen/keen-cli/issues).
|
9
|
+
|
7
10
|
### Installation
|
8
11
|
|
9
12
|
keen-cli is built with Ruby, so you'll need a working Ruby 1.9+ environment to use it. You can find Ruby installation instructions [here](https://www.ruby-lang.org/en/installation/).
|
@@ -127,35 +130,37 @@ $ keen events:add --collection signups
|
|
127
130
|
# use the shorter form of collection
|
128
131
|
$ keen events:add -c signups
|
129
132
|
|
130
|
-
# add a blank event to a collection specified
|
131
|
-
|
132
|
-
$ keen events:add
|
133
|
+
# add a blank event to a collection specified by the environment:
|
134
|
+
$ KEEN_COLLECTION_NAME=signups keen events:add
|
133
135
|
|
134
136
|
# add an event from JSON using the --data parameter
|
135
137
|
$ keen events:add -c signups --data "{ \"username\" : \"dzello\", \"city\": \"San Francisco\" }"
|
136
138
|
|
137
|
-
# add an event from key value pairs
|
139
|
+
# add an event from key value pairs using the --params parameter
|
138
140
|
$ keen events:add -c signups -data "username=dzello&city=SF" --params
|
139
141
|
|
140
|
-
# pipe in events as JSON
|
141
|
-
$ echo "{ \"username\" : \"dzello\", \"city\": \"San Francisco\" }" | keen events:add -c signups
|
142
|
-
|
143
142
|
# add events from a file that contains newline delimited json:
|
144
143
|
# { "username" : "dzello", "city" : "San Francisco" }
|
145
144
|
# { "username" : "KarlTheFog", "city" : "San Francisco" }
|
146
145
|
# { "username" : "polarvortex", "city" : "Chicago" }
|
147
|
-
$ keen events:add --file events.json
|
146
|
+
$ keen events:add -c signups --file events.json
|
148
147
|
|
149
148
|
# add events from a file that contains an array of JSON objects
|
150
149
|
# [{ "apple" : "sauce" }, { "banana" : "pudding" }, { "cherry" : "pie" }]
|
151
|
-
$ keen events:add --file events.json
|
150
|
+
$ keen events:add -c signups --file events.json
|
152
151
|
|
153
152
|
# add events from a file in CSV format. the first row must be column names:
|
154
153
|
# username, city
|
155
154
|
# dzello, San Francisco
|
156
155
|
# KarlTheFog, San Francisco
|
157
156
|
# polarvortex, Chicago
|
158
|
-
$ keen events:add --file events.csv --csv
|
157
|
+
$ keen events:add -c signups --file events.csv --csv
|
158
|
+
|
159
|
+
# pipe in an event as JSON
|
160
|
+
$ echo "{ \"username\" : \"dzello\", \"city\": \"San Francisco\" }" | keen events:add -c signups
|
161
|
+
|
162
|
+
# pipe in multiple events as newline-delimited JSON
|
163
|
+
$ cat events.json | keen events:add -c signups
|
159
164
|
```
|
160
165
|
|
161
166
|
Notes:
|
@@ -192,20 +197,20 @@ Some examples:
|
|
192
197
|
|
193
198
|
``` shell
|
194
199
|
# run a count
|
195
|
-
$ keen queries:run --collection signups --analysis-type count
|
200
|
+
$ keen queries:run --collection signups --analysis-type count --timeframe this_14_days
|
196
201
|
{
|
197
202
|
"result": 1000
|
198
203
|
}
|
199
204
|
|
200
205
|
# run a count with collection name from .env
|
201
206
|
# KEEN_COLLECTION_NAME=signups
|
202
|
-
$ keen queries:run --analysis-type count
|
207
|
+
$ keen queries:run --analysis-type count --timeframe this_14_days
|
203
208
|
{
|
204
209
|
"result": 1000
|
205
210
|
}
|
206
211
|
|
207
212
|
# run a count with a group by
|
208
|
-
$ keen queries:run --collection signups --analysis-type count --group-by username
|
213
|
+
$ keen queries:run --collection signups --analysis-type count --group-by username --timeframe this_14_days
|
209
214
|
{
|
210
215
|
"result": [
|
211
216
|
{
|
@@ -216,7 +221,7 @@ $ keen queries:run --collection signups --analysis-type count --group-by usernam
|
|
216
221
|
}
|
217
222
|
|
218
223
|
# run a query with a timeframe, target property, group by, and interval
|
219
|
-
$ keen queries:run --collection signups --analysis-type count_unique --target-property age --group-by source --timeframe
|
224
|
+
$ keen queries:run --collection signups --analysis-type count_unique --target-property age --group-by source --timeframe previous_24_hours --interval hourly
|
220
225
|
{
|
221
226
|
"result": [
|
222
227
|
{
|
@@ -238,7 +243,7 @@ $ keen queries:run --analysis-type count --start 2014-07-01T00:00:00Z --end 2014
|
|
238
243
|
}
|
239
244
|
|
240
245
|
# run an extraction with specific property names
|
241
|
-
$ keen queries:run --collection minecraft-deaths --analysis-type extraction --property-names player,enemy
|
246
|
+
$ keen queries:run --collection minecraft-deaths --analysis-type extraction --property-names player,enemy --timeframe this_14_days
|
242
247
|
{
|
243
248
|
"result": [
|
244
249
|
{
|
@@ -253,7 +258,7 @@ $ keen queries:run --collection minecraft-deaths --analysis-type extraction --pr
|
|
253
258
|
}
|
254
259
|
|
255
260
|
# run a query using JSON to specify parameters
|
256
|
-
$ echo "{ \"event_collection\" : \"minecraft-deaths\", \"target_property\": \"level\" }" | keen queries:run -a average
|
261
|
+
$ echo "{ \"event_collection\" : \"minecraft-deaths\", \"target_property\": \"level\" , \"timeframe\": \"this_14_days\" }" | keen queries:run -a average
|
257
262
|
{
|
258
263
|
"result": 2
|
259
264
|
}
|
@@ -268,7 +273,7 @@ Run `keen` with no arguments to see the full list of aliases.
|
|
268
273
|
The same parameters apply as `queries:run`, in addition to one extra.
|
269
274
|
|
270
275
|
+ `--exclude-api-key`: Prevent the API key query param from being included in the output
|
271
|
-
|
276
|
+
|
272
277
|
**Query Aliases**
|
273
278
|
|
274
279
|
For each type of analysis (e.g. count, average, extraction, etc.) there is an alias that can be used
|
data/Rakefile
CHANGED
data/keen-cli.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
s.add_development_dependency 'rake'
|
20
20
|
s.add_development_dependency 'rspec'
|
21
|
-
s.add_development_dependency '
|
21
|
+
s.add_development_dependency 'byebug'
|
22
22
|
s.add_development_dependency 'webmock'
|
23
23
|
|
24
24
|
s.files = `git ls-files`.split("\n")
|
@@ -93,6 +93,17 @@ module KeenCli
|
|
93
93
|
keen.delete("created_at")
|
94
94
|
end
|
95
95
|
|
96
|
+
# Set the keen.location.coordinates to a true array
|
97
|
+
if event["keen"] and event["keen"]["location"] and event["keen"]["location"]["coordinates"]
|
98
|
+
coordinates = event["keen"]["location"]["coordinates"]
|
99
|
+
|
100
|
+
if coordinates and coordinates[0] == "[" and coordinates[coordinates.length-1] == "]"
|
101
|
+
event["keen"]["location"]["coordinates"] = coordinates[1..coordinates.length-2].split(',').map(&:to_f)
|
102
|
+
elsif coordinates.class != Array # This should never happen, but just in case..
|
103
|
+
event["keen"].delete("location")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
96
107
|
self.events.push(event)
|
97
108
|
self.size += 1
|
98
109
|
self.total_size += 1
|
data/lib/keen-cli/version.rb
CHANGED
@@ -166,6 +166,11 @@ module KeenCli
|
|
166
166
|
expect(batch_processor.events.first).to eq({ "keen" => {} })
|
167
167
|
end
|
168
168
|
|
169
|
+
it 'reformats the keen.location.coordinates property' do
|
170
|
+
batch_processor.add('{ "keen": { "location": { "coordinates": "[12.12, 34.34]" } } }')
|
171
|
+
expect(batch_processor.events.first).to eq({"keen" => { "location" => { "coordinates" => [12.12, 34.34] } } })
|
172
|
+
end
|
173
|
+
|
169
174
|
end
|
170
175
|
|
171
176
|
describe 'flush' do
|
metadata
CHANGED
@@ -1,126 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keen-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Josh Dzielak
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: keen
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.8.8
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.8.8
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: thor
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: dotenv
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rspec
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
84
|
+
name: byebug
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: webmock
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
description: Record events and run queries from the comfort of your command line
|
@@ -130,8 +115,8 @@ executables:
|
|
130
115
|
extensions: []
|
131
116
|
extra_rdoc_files: []
|
132
117
|
files:
|
133
|
-
- .gitignore
|
134
|
-
- .travis.yml
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
135
120
|
- Gemfile
|
136
121
|
- LICENSE
|
137
122
|
- README.md
|
@@ -161,27 +146,26 @@ files:
|
|
161
146
|
homepage: https://github.com/keenlabs/keen-cli
|
162
147
|
licenses:
|
163
148
|
- MIT
|
149
|
+
metadata: {}
|
164
150
|
post_install_message:
|
165
151
|
rdoc_options: []
|
166
152
|
require_paths:
|
167
153
|
- lib
|
168
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
155
|
requirements:
|
171
|
-
- -
|
156
|
+
- - ">="
|
172
157
|
- !ruby/object:Gem::Version
|
173
158
|
version: '0'
|
174
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
160
|
requirements:
|
177
|
-
- -
|
161
|
+
- - ">="
|
178
162
|
- !ruby/object:Gem::Version
|
179
163
|
version: '0'
|
180
164
|
requirements: []
|
181
165
|
rubyforge_project:
|
182
|
-
rubygems_version:
|
166
|
+
rubygems_version: 2.4.5.1
|
183
167
|
signing_key:
|
184
|
-
specification_version:
|
168
|
+
specification_version: 4
|
185
169
|
summary: Command line interface to Keen IO
|
186
170
|
test_files:
|
187
171
|
- spec/fixtures/events-array.json
|
@@ -194,4 +178,3 @@ test_files:
|
|
194
178
|
- spec/keen-cli/projects_spec.rb
|
195
179
|
- spec/keen-cli/queries_spec.rb
|
196
180
|
- spec/spec_helper.rb
|
197
|
-
has_rdoc:
|