pathways 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +198 -0
- data/lib/pathways/parser.rb +2 -2
- data/lib/pathways/version.rb +1 -1
- data/pathways.gemspec +1 -1
- metadata +6 -5
data/README.markdown
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
Pathways
|
2
|
+
========
|
3
|
+
|
4
|
+
Pathways allows you to see the pathways that users are using within your application. When we can see the flows through the app then we can pave the cowpaths and validate the features that we build.
|
5
|
+
|
6
|
+
Pathways uses your default Rails logger to store the information from a successful response so it doesn't slow our request/response cycle. We can then parse the logfile and store the results in a MongoDB database at a later date.
|
7
|
+
|
8
|
+
### Another set of Metrics?
|
9
|
+
|
10
|
+
Pathways was created so that we can understand the impact of our development on the behaviour of our users. Metrics shouldn't just be about page view counters it should understand where the user has been within that viewing session. By using a non relational database like MongoDB we can map_reduce all the pages that a user visits in a session so that we can truly analyse what is going on within our applications.
|
11
|
+
|
12
|
+
|
13
|
+
The Blog Post
|
14
|
+
-------------
|
15
|
+
|
16
|
+
For the backstory, philosophy, and history of why we created Pathways,
|
17
|
+
please see [the blog post][0].
|
18
|
+
|
19
|
+
|
20
|
+
Overview
|
21
|
+
--------
|
22
|
+
|
23
|
+
Pathways allows you to track the flow users take within your application. Each successful request is logged into your Rails.logger which can then be asynchronously parsed and stored in a MongoDB table later.
|
24
|
+
|
25
|
+
Tracker
|
26
|
+
-------
|
27
|
+
|
28
|
+
To start tracking the paths your users are taking all you need to do is add this to your controllers.
|
29
|
+
|
30
|
+
``` ruby
|
31
|
+
class ApplicationController
|
32
|
+
include Pathways::Tracker
|
33
|
+
after_filter :log_visit
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
This will create an entry in your default logfile that is later collected and parsed by Pathways.
|
38
|
+
|
39
|
+
### Iteration
|
40
|
+
|
41
|
+
You can also track the iteration/deployment that is currently running so that we can easily track the impact of each deployment.
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
class ApplicationController
|
45
|
+
include Pathways::Tracker
|
46
|
+
after_filter :log_visit
|
47
|
+
Pathways::Tracker.iteration = "iteration-001"
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
Parser
|
52
|
+
------
|
53
|
+
|
54
|
+
Now that we're tracking the paths our users take we need to parse these so that we can mine this like a mofo.
|
55
|
+
|
56
|
+
Pathways::Parser.execute
|
57
|
+
|
58
|
+
This will run ever 5 seconds and create records for Pathways::Session and Pathways::Visits. By default this will look at the development.log using Rails.root.
|
59
|
+
|
60
|
+
If you want to specify the name of the logfile then you can pass it as the first parameter.
|
61
|
+
|
62
|
+
Pathways::Parser.execute("production")
|
63
|
+
|
64
|
+
You can also control the interval (in seconds) that parser will check your logfile, the default is set to 60 seconds.
|
65
|
+
|
66
|
+
Pathways::Tracker.iteration("production",10)
|
67
|
+
|
68
|
+
The Front End
|
69
|
+
-------------
|
70
|
+
|
71
|
+
Pathways has a huge crush on Resque, so like Resque it comes with a Sinatra-based front end for seeing the sessions users are creating in your app.
|
72
|
+
|
73
|
+
### Standalone
|
74
|
+
|
75
|
+
If you've installed Pathways as a gem running the front end standalone is easy:
|
76
|
+
|
77
|
+
$ pathways-web
|
78
|
+
|
79
|
+
It's a thin layer around `rackup` so it's configurable as well:
|
80
|
+
|
81
|
+
$ pathways-web -p 8282
|
82
|
+
|
83
|
+
### Passenger
|
84
|
+
|
85
|
+
Using Passenger? Resque ships with a `config.ru` you can use. See
|
86
|
+
Phusion's guide:
|
87
|
+
|
88
|
+
Apache: <http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_rack_based_ruby_application>
|
89
|
+
Nginx: <http://www.modrails.com/documentation/Users%20guide%20Nginx.html#deploying_a_rack_app>
|
90
|
+
|
91
|
+
### Rack::URLMap
|
92
|
+
|
93
|
+
If you want to load Resque on a subpath, possibly alongside other
|
94
|
+
apps, it's easy to do with Rack's `URLMap`:
|
95
|
+
|
96
|
+
``` ruby
|
97
|
+
require 'pathways/server'
|
98
|
+
|
99
|
+
run Rack::URLMap.new \
|
100
|
+
"/" => Your::App.new,
|
101
|
+
"/pathways" => Pathways::Server.new
|
102
|
+
```
|
103
|
+
|
104
|
+
### Rails 3
|
105
|
+
|
106
|
+
You can also easily mount Resque on a subpath in your existing Rails 3 app by adding this to your `routes.rb`:
|
107
|
+
|
108
|
+
``` ruby
|
109
|
+
mount Pathways::Server.new, :at => "/pathways"
|
110
|
+
```
|
111
|
+
|
112
|
+
|
113
|
+
Installing MongoDB
|
114
|
+
------------------
|
115
|
+
|
116
|
+
Pathways requires MongoDB.
|
117
|
+
|
118
|
+
|
119
|
+
#### Homebrew
|
120
|
+
|
121
|
+
If you're on OS X, Homebrew is the simplest way to install MongoDB:
|
122
|
+
|
123
|
+
$ brew install mongodb
|
124
|
+
$ mongod run --config /usr/local/Cellar/mongodb/1.8.1-x86_64/mongod.conf
|
125
|
+
|
126
|
+
You now have a MongoDB instance running on 27017.
|
127
|
+
|
128
|
+
|
129
|
+
Pathways Dependencies
|
130
|
+
---------------------
|
131
|
+
|
132
|
+
$ gem install bundler
|
133
|
+
$ bundle install
|
134
|
+
|
135
|
+
|
136
|
+
Installing Pathways
|
137
|
+
-----------------
|
138
|
+
|
139
|
+
### In a Rails 2.x app, as a gem
|
140
|
+
|
141
|
+
First install the gem.
|
142
|
+
|
143
|
+
$ gem install resque
|
144
|
+
|
145
|
+
Next include it in your application.
|
146
|
+
|
147
|
+
$ cat config/initializers/load_pathways.rb
|
148
|
+
require 'resque'
|
149
|
+
|
150
|
+
Now start your application:
|
151
|
+
|
152
|
+
$ ./script/server
|
153
|
+
|
154
|
+
Ta da! Your application is now logging the pathways your users make.
|
155
|
+
|
156
|
+
### In a Rails 3 app, as a gem
|
157
|
+
|
158
|
+
First include it in your Gemfile.
|
159
|
+
|
160
|
+
$ cat Gemfile
|
161
|
+
...
|
162
|
+
gem 'pathways'
|
163
|
+
...
|
164
|
+
|
165
|
+
Next install it with Bundler.
|
166
|
+
|
167
|
+
$ bundle install
|
168
|
+
|
169
|
+
Now start your application:
|
170
|
+
|
171
|
+
$ rails server
|
172
|
+
|
173
|
+
Ta da! Your application is now logging the pathways your users make.
|
174
|
+
|
175
|
+
|
176
|
+
Contributing
|
177
|
+
------------
|
178
|
+
|
179
|
+
Once you've made your great commits:
|
180
|
+
|
181
|
+
1. [Fork][1] Pathways
|
182
|
+
2. Create a topic branch - `git checkout -b my_branch`
|
183
|
+
3. Push to your branch - `git push origin my_branch`
|
184
|
+
4. Create a [Pull Request](http://help.github.com/pull-requests/) from your branch
|
185
|
+
5. That's it!
|
186
|
+
|
187
|
+
Meta
|
188
|
+
----
|
189
|
+
|
190
|
+
* Code: `git clone git://github.com/simonreed/pathways.git`
|
191
|
+
* Bugs: <http://github.com/simonreed/pathways/issues>
|
192
|
+
|
193
|
+
Author
|
194
|
+
------
|
195
|
+
|
196
|
+
Simon Reed :: simon@mintdigital.com :: @simonreed
|
197
|
+
|
198
|
+
[0]: http://logicalfriday.com/2011/08/25/dont-build-that-feature/
|
data/lib/pathways/parser.rb
CHANGED
@@ -9,13 +9,13 @@ module Pathways
|
|
9
9
|
@log = File.open( path )
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.execute(env="development")
|
12
|
+
def self.execute(env="development", interval_seconds=60)
|
13
13
|
parser = self.new(env)
|
14
14
|
most_recent_session_updated_at = Pathways::Session.first(:order => "updated_at DESC").try(:updated_at)
|
15
15
|
while true
|
16
16
|
puts "Processing"
|
17
17
|
parser.run(most_recent_session_updated_at)
|
18
|
-
sleep
|
18
|
+
sleep interval_seconds.to_i;
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/lib/pathways/version.rb
CHANGED
data/pathways.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Mint Digital","Simon Reed"]
|
9
9
|
s.email = ["hello@mintdigital.com","min.sucks@gmail.com"]
|
10
|
-
s.homepage = "http://
|
10
|
+
s.homepage = "http://github.com/simonreed/pathways"
|
11
11
|
s.summary = "Helps your track the pathways in your Rails app."
|
12
12
|
s.description = "Helps your track the pathways in your app so that you can pave the cowpaths. Uses MongoDB to traverse the paths looking for little nuggets."
|
13
13
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathways
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mint Digital
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-09-
|
19
|
+
date: 2011-09-19 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -111,6 +111,7 @@ extra_rdoc_files: []
|
|
111
111
|
files:
|
112
112
|
- .gitignore
|
113
113
|
- Gemfile
|
114
|
+
- README.markdown
|
114
115
|
- Rakefile
|
115
116
|
- bin/pathways-web
|
116
117
|
- bin/pathways-worker
|
@@ -141,7 +142,7 @@ files:
|
|
141
142
|
- lib/tasks/pathways.rake
|
142
143
|
- pathways.gemspec
|
143
144
|
has_rdoc: true
|
144
|
-
homepage: http://
|
145
|
+
homepage: http://github.com/simonreed/pathways
|
145
146
|
licenses: []
|
146
147
|
|
147
148
|
post_install_message:
|