pushpop-keen 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +16 -0
- data/lib/pushpop-keen.rb +13 -2
- data/lib/pushpop-keen/version.rb +1 -1
- data/spec/pushpop-keen_spec.rb +45 -0
- metadata +11 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f99b446d23b1ca7d137d3975b44f0416d6c7181
|
4
|
+
data.tar.gz: 3db767ef6814b271c2d7ea6641cffe1457e170d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c97d92e2f35d54f07fb0035b52afaf0e6a16597544ed1444cd505de453b6a03b44f29ac23bc52ffe3c8b005fabefcad9aaf10953faf6be193860031687c48089
|
7
|
+
data.tar.gz: d884e5c7a1d2f963bcf80287c390227056f9cd0971cb0f1aa28d4761b123e4ee9e542115dc203b577b4dd0ffda85827b261479d833d0f059b2b690ad29047475
|
data/README.md
CHANGED
@@ -18,6 +18,8 @@ $ gem install pushpop-keen
|
|
18
18
|
|
19
19
|
### Usage
|
20
20
|
|
21
|
+
#### Querying
|
22
|
+
|
21
23
|
The `keen` plugin gives you a DSL to specify Keen query parameters. Those query parameters are used to query data using the [keen-gem](https://github.com/keenlabs/keen-gem).
|
22
24
|
|
23
25
|
Here's an example that shows many of the options you can specify:
|
@@ -43,6 +45,20 @@ end
|
|
43
45
|
A `steps` method is also supported for [funnels](https://keen.io/docs/data-analysis/funnels/),
|
44
46
|
as well as `analyses` for doing a [multi-analysis](https://keen.io/docs/data-analysis/multi-analysis/).
|
45
47
|
|
48
|
+
#### Tracking
|
49
|
+
|
50
|
+
You can also very simply record events to Keen:
|
51
|
+
|
52
|
+
``` ruby
|
53
|
+
job 'send pageview'
|
54
|
+
|
55
|
+
keen do
|
56
|
+
record 'Pageview', path: '/a/path'
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
46
62
|
The `keen` plugin requires that the following environment variables are set:
|
47
63
|
|
48
64
|
+ `KEEN_PROJECT_ID`
|
data/lib/pushpop-keen.rb
CHANGED
@@ -20,14 +20,25 @@ module Pushpop
|
|
20
20
|
attr_accessor :_analyses
|
21
21
|
|
22
22
|
def run(last_response=nil, step_responses=nil)
|
23
|
-
self.configure(last_response, step_responses)
|
24
|
-
|
23
|
+
ret = self.configure(last_response, step_responses)
|
24
|
+
|
25
|
+
if self._analysis_type == 'funnel'
|
26
|
+
::Keen.funnel(self.to_analysis_options)
|
27
|
+
elsif !self._analysis_type.nil?
|
28
|
+
::Keen.send(self._analysis_type, self._event_collection, self.to_analysis_options)
|
29
|
+
else
|
30
|
+
ret
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
34
|
def configure(last_response=nil, step_responses=nil)
|
28
35
|
self.instance_exec(last_response, step_responses, &block)
|
29
36
|
end
|
30
37
|
|
38
|
+
def record(name, properties)
|
39
|
+
::Keen.publish(name, properties)
|
40
|
+
end
|
41
|
+
|
31
42
|
def to_analysis_options
|
32
43
|
{ timeframe: self._timeframe,
|
33
44
|
target_property: self._target_property,
|
data/lib/pushpop-keen/version.rb
CHANGED
data/spec/pushpop-keen_spec.rb
CHANGED
@@ -37,6 +37,17 @@ describe Pushpop::Keen do
|
|
37
37
|
|
38
38
|
end
|
39
39
|
|
40
|
+
describe '#record' do
|
41
|
+
it 'should record an event with properties' do
|
42
|
+
step = Pushpop::Keen.new do
|
43
|
+
record 'Pageview', useragent: 'Chrome'
|
44
|
+
end
|
45
|
+
|
46
|
+
expect(Keen).to receive(:publish).with('Pageview', useragent: 'Chrome')
|
47
|
+
step.run
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
40
51
|
describe '#run' do
|
41
52
|
it 'should run the query based on the analysis type' do
|
42
53
|
Keen.stub(:count).with('pageviews', {
|
@@ -51,6 +62,40 @@ describe Pushpop::Keen do
|
|
51
62
|
response = step.run
|
52
63
|
response.should == 365
|
53
64
|
end
|
65
|
+
|
66
|
+
it 'should not try to run a query if the analysis type isnt set' do
|
67
|
+
step = Pushpop::Keen.new do
|
68
|
+
group_by 'something'
|
69
|
+
end
|
70
|
+
|
71
|
+
expect(Keen).not_to receive(:send)
|
72
|
+
expect(Keen).not_to receive(:funnel)
|
73
|
+
|
74
|
+
step.run
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should run funnels directly, instead of using send' do
|
78
|
+
step = Pushpop::Keen.new('one') do
|
79
|
+
analysis_type 'funnel'
|
80
|
+
steps [
|
81
|
+
{
|
82
|
+
actor_property: 'uuid',
|
83
|
+
event_collection: 'pageviews',
|
84
|
+
timeframe: 'this_3_days'
|
85
|
+
},
|
86
|
+
{
|
87
|
+
actor_property: 'uuid',
|
88
|
+
event_collection: 'link_clicks',
|
89
|
+
timeframe: 'this_3_days'
|
90
|
+
}
|
91
|
+
]
|
92
|
+
end
|
93
|
+
|
94
|
+
expect(Keen).to receive(:funnel)
|
95
|
+
expect(Keen).not_to receive(:send)
|
96
|
+
|
97
|
+
step.run
|
98
|
+
end
|
54
99
|
end
|
55
100
|
|
56
101
|
describe '#to_analysis_options' do
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushpop-keen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.2'
|
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: 2015-05-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: pushpop
|
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'
|
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'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: keen
|
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
|
description:
|
@@ -62,27 +57,26 @@ files:
|
|
62
57
|
- spec/spec_helper.rb
|
63
58
|
homepage: https://github.com/pushpop-project/pushpop-keen
|
64
59
|
licenses: []
|
60
|
+
metadata: {}
|
65
61
|
post_install_message:
|
66
62
|
rdoc_options: []
|
67
63
|
require_paths:
|
68
64
|
- lib
|
69
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
66
|
requirements:
|
72
|
-
- -
|
67
|
+
- - '>='
|
73
68
|
- !ruby/object:Gem::Version
|
74
69
|
version: '0'
|
75
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
71
|
requirements:
|
78
|
-
- -
|
72
|
+
- - '>='
|
79
73
|
- !ruby/object:Gem::Version
|
80
74
|
version: '0'
|
81
75
|
requirements: []
|
82
76
|
rubyforge_project:
|
83
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.0.14
|
84
78
|
signing_key:
|
85
|
-
specification_version:
|
79
|
+
specification_version: 4
|
86
80
|
summary: Pushpop Keen IO plugin for querying and recording events
|
87
81
|
test_files:
|
88
82
|
- spec/pushpop-keen_spec.rb
|