charted 0.0.2 → 0.0.3
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.md +57 -5
- data/charted +2 -3
- data/lib/charted.rb +3 -2
- data/test/charted_test.rb +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
Description
|
2
2
|
===========
|
3
3
|
|
4
|
-
Charted is a minimal web traffic analytics app.
|
4
|
+
Charted is a minimal web traffic analytics app.
|
5
5
|
|
6
6
|
Installation
|
7
7
|
============
|
8
8
|
|
9
9
|
$ gem install charted
|
10
10
|
|
11
|
+
Also install the relevant database adapter, depending on which db you plan to use:
|
12
|
+
|
13
|
+
$ gem install dm-mysql-adapter
|
14
|
+
|
11
15
|
Setup a `config.ru` file and run it like any other Sinatra application.
|
12
16
|
|
13
17
|
require 'rubygems'
|
@@ -49,6 +53,10 @@ Updating
|
|
49
53
|
========
|
50
54
|
|
51
55
|
$ gem install charted
|
56
|
+
|
57
|
+
If you concatenated the JavaScript, you may need to do it again:
|
58
|
+
|
59
|
+
$ charted --js > /path/to/my/project/public/charted.js
|
52
60
|
|
53
61
|
Usage
|
54
62
|
=====
|
@@ -56,8 +64,7 @@ Usage
|
|
56
64
|
The web application is for end users, to get information about your traffic use
|
57
65
|
the included command line application.
|
58
66
|
|
59
|
-
$ charted --
|
60
|
-
$ charted --dashboard --site hugh # just needs the first few letters
|
67
|
+
$ charted --site hugh # just needs the first few letters
|
61
68
|
+-------+--------+--------------------------------------+
|
62
69
|
| Total | Unique | Visits |
|
63
70
|
+-------+--------+--------------------------------------+
|
@@ -66,6 +73,47 @@ the included command line application.
|
|
66
73
|
| 5,342 | 3,988 | December 2012 |
|
67
74
|
...
|
68
75
|
|
76
|
+
Basic tracking of common stats like visits, referrers, or user agents are done
|
77
|
+
automatically. You can also track events, conversions, and experiments.
|
78
|
+
|
79
|
+
Events can be recorded with JavaScript:
|
80
|
+
|
81
|
+
Charted.events("1st Button Clicked");
|
82
|
+
Charted.events("1st Button Clicked", "2nd Button Clicked");
|
83
|
+
|
84
|
+
To start a conversion, you'll need to set the `data-conversions` attribute of
|
85
|
+
the `<body>` element:
|
86
|
+
|
87
|
+
<body data-conversions="RSS Subscribed; Item Purchased">
|
88
|
+
|
89
|
+
Just separate goal names with a semi-colon. When the conversion goal has been
|
90
|
+
reached:
|
91
|
+
|
92
|
+
Charted.goals("RSS Subscribed");
|
93
|
+
Charted.goals("RSS Subscribed", "Item Purchased"); // calls can be batched
|
94
|
+
|
95
|
+
Experiments use the `data-experiments` attribute and use the format
|
96
|
+
`experiment: bucket1, bucket2, ...`:
|
97
|
+
|
98
|
+
<body data-experiments="Buy Button: Blue, Green, Red">
|
99
|
+
|
100
|
+
The included JavaScript will automatically select a bucket for this user and
|
101
|
+
append a relevant class name to the `<body>` element like:
|
102
|
+
|
103
|
+
<body class="buy-button-green">
|
104
|
+
|
105
|
+
The class name is just the experiment label and bucket lowercased with spaces
|
106
|
+
replaced with dashes. Use CSS to tweak the buy button. When a user clicks
|
107
|
+
on a button, use JavaScript to send a message to the server:
|
108
|
+
|
109
|
+
Charted.goals("Buy Button");
|
110
|
+
|
111
|
+
Running `charted --clean` will prune the database of old data. I recommend
|
112
|
+
putting this as a cronjob. It can also be used to remove bad entries in the
|
113
|
+
events/conversions/experiments table:
|
114
|
+
|
115
|
+
charted --clean "Buy Button"
|
116
|
+
|
69
117
|
Development
|
70
118
|
===========
|
71
119
|
|
@@ -86,8 +134,12 @@ Tests are setup to run via `ruby test/*_test.rb` or via `rake`.
|
|
86
134
|
TODO
|
87
135
|
====
|
88
136
|
|
89
|
-
*
|
90
|
-
*
|
137
|
+
* don't catch-all load error, makes debugging config.ru difficult
|
138
|
+
* fix sorting
|
139
|
+
* fix search terms
|
140
|
+
* consider removing colored titles
|
141
|
+
* shorten lists (too many single entries) on dashboard, add --full?
|
142
|
+
* browser version (IE6, IE7, IE8...) ?
|
91
143
|
|
92
144
|
License
|
93
145
|
=======
|
data/charted
CHANGED
@@ -8,15 +8,14 @@ require 'fileutils'
|
|
8
8
|
ENV['CHARTED_CMD'] = '1'
|
9
9
|
|
10
10
|
ARGV.options do |o|
|
11
|
-
cmd, action = Charted::Command.new,
|
11
|
+
cmd, action = Charted::Command.new, [:dashboard]
|
12
12
|
o.set_summary_indent(' ')
|
13
13
|
o.banner = "Usage: #{File.basename($0)} [OPTION]"
|
14
14
|
o.on('-c', '--clean [label]', 'clean out old data') { |label| action = [:clean, label] }
|
15
|
-
o.on('-d', '--dashboard', 'show dashboard') { action = [:dashboard] }
|
16
15
|
o.on('-h', '--help', 'show this help message') { puts o; exit }
|
17
16
|
o.on('-j', '--js', 'output js code') { action = [:js] }
|
18
17
|
o.on('-m', '--migrate', 'migrates database') { cmd.migrate; exit }
|
19
18
|
o.on('-s', '--site domain', 'set site') { |site| cmd.site = site }
|
20
19
|
o.parse!
|
21
|
-
|
20
|
+
cmd.send(*action.compact)
|
22
21
|
end
|
data/lib/charted.rb
CHANGED
@@ -19,7 +19,7 @@ require 'dashes'
|
|
19
19
|
DataMapper::Model.raise_on_save_failure = true
|
20
20
|
|
21
21
|
module Charted
|
22
|
-
VERSION = '0.0.
|
22
|
+
VERSION = '0.0.3'
|
23
23
|
GEOIP = GeoIP.new("#{File.dirname(__FILE__)}/../geoip.dat")
|
24
24
|
JS_FILE = "#{File.dirname(__FILE__)}/../public/charted/script.js"
|
25
25
|
|
@@ -272,7 +272,8 @@ module Charted
|
|
272
272
|
expires: (Date.today + 365*2).to_time)
|
273
273
|
end
|
274
274
|
|
275
|
-
referrer =
|
275
|
+
referrer = params[:referrer].to_s
|
276
|
+
referrer = nil if URI.parse(referrer).host == @site.domain || referrer =~ /^\s*$/
|
276
277
|
@visitor.visits.create(
|
277
278
|
path: params[:path],
|
278
279
|
title: params[:title],
|
data/test/charted_test.rb
CHANGED
@@ -179,7 +179,7 @@ class AppTest < ChartedTest
|
|
179
179
|
:bucket => 1,
|
180
180
|
:path => '/',
|
181
181
|
:title => 'Prime',
|
182
|
-
:referrer => 'localhost',
|
182
|
+
:referrer => 'http://localhost/?k=v',
|
183
183
|
:resolution => '1280x800'
|
184
184
|
}
|
185
185
|
@env = {
|
@@ -212,7 +212,7 @@ class AppTest < ChartedTest
|
|
212
212
|
assert_equal(@site, visit.site)
|
213
213
|
assert_equal('Prime', visit.title)
|
214
214
|
assert_equal('/', visit.path)
|
215
|
-
assert_equal(
|
215
|
+
assert_equal('http://localhost/?k=v', visit.referrer)
|
216
216
|
assert_equal('1280x800', visitor.resolution)
|
217
217
|
assert_equal('United States', visitor.country)
|
218
218
|
assert_equal(visitor.cookie, rack_mock_session.cookie_jar['charted'])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: .
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|