saw 0.0.2 → 0.0.3

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: 201ccb92480175264bc7cb5955186328323c21a4
4
- data.tar.gz: 2b4b6f7485a01ccd81e536e9d524246c688465dc
3
+ metadata.gz: b24e7857a6b04db861aa6a2d7619eb49aa32f650
4
+ data.tar.gz: f1eb037fbf8a252336b49a19fe6f370f95400893
5
5
  SHA512:
6
- metadata.gz: 50b0a2956314584084cd0d4f2d1861dcb4c68701717f23243aed65b5fb565e5d96e32ba830287e973fbaaef7243dafe461aae2f256e87ec439dace92fe98c709
7
- data.tar.gz: bf81963f5228ba8ef6d6c0cff3861b84dbcdd2d6474a9887b50ab848af3015a010affe2f5331184b6eb6f52f2a59241946801ed084aa0496f28991df9d1f0695
6
+ metadata.gz: b0f15a0c4da218986cf43bd8c94f61c461ce765d654f43b9f22785d30e16a4774fb9c806481e6a0225a47122a7c2961c38eefa3a29eee861505da7b0f828a492
7
+ data.tar.gz: 1a219ea218250fdc53349bcbad50ef99c8b88dbe35b5bb29600bd9e8ee035a92e1db86fb3317326ae7381905006c3e50c9d3545d387471f03b5854bc8fae0a33
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Saw
2
2
 
3
- TODO: Write a gem description
3
+ As a developer/admin, I saw user coming to registration page, with parameters. I saw user clking on "Connect".
4
+
5
+ `What the user might have done?` this is a common question developers do have while debugging any issue, going through the logs checking for particular log statement or request param, and then after spending an hour coming with a decision that user must have done this. Saw saves this hour, time spent on debugging and answering this question `What user might have done?`.
6
+
7
+ This is one more simply way to track what user is doing.
4
8
 
5
9
  ## Installation
6
10
 
@@ -10,20 +14,62 @@ Add this line to your application's Gemfile:
10
14
 
11
15
  And then execute:
12
16
 
13
- $ bundle
17
+ $ bundle install
14
18
 
15
19
  Or install it yourself as:
16
20
 
17
21
  $ gem install saw
18
22
 
23
+ And then install
24
+
25
+ $ rails generate saw install
26
+
27
+ Next
28
+
29
+ $ rake db:migrate
30
+
19
31
  ## Usage
20
32
 
21
- TODO: Write usage instructions here
33
+ before_filter :saw
34
+
35
+ Or
36
+
37
+ saw 'visiting details page', { :extra => 'something' }
38
+
39
+ Or
40
+
41
+ # in views
42
+
43
+ <button id="button-retry" onclick="open_pop_up_form();" class="mybutton medium green">
44
+ Connect to your Device
45
+ </button>
46
+
47
+ <script type="text/javascript">
48
+ function open_pop_up_form(){
49
+ $.post("/visits", { doing: "clicked on 'Connect to your Device' " } );
50
+ ....
51
+
52
+ Access users' visits as
53
+
54
+ visit = @user.visits.sample
55
+ visit.user_agent
56
+ visit.remote_host
57
+ visit.hits.map(&:note)
58
+ visit.lasts # => 00:12:45
59
+ visit.title # => 00:12:45 on Apr 14, 2013
60
+ visit.summary
61
+
62
+ hit = visit.hits.sample
63
+ hit.note
64
+ hit.url
65
+ hit.http_method
66
+ hit.action
67
+ hit.json_data
68
+ hit.created_at
69
+
70
+ A visit is not a single request made to the server but a session. Similalry a hit is not necessary to be a request hit.
71
+
72
+ ## Testing (TBD)
22
73
 
23
- ## Contributing
74
+ ruby test/saw_test.rb
24
75
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
@@ -2,17 +2,18 @@ ActiveAdmin.register Visit do
2
2
  menu :parent => "Users"
3
3
  belongs_to :user, :optional => true
4
4
 
5
- actions :all, :except => [:edit, :update, :create]
5
+ actions :index, :show, :destroy
6
6
 
7
7
  index do
8
8
  selectable_column
9
9
 
10
- column "" do |resource|
11
- links = ''
12
- links << link_to("#{resource.hits.count} hits", admin_visit_hits_path(resource))
13
- links << " by "
14
- links << link_to("#{resource.user.username}", admin_user_path(resource.user))
15
- links.html_safe
10
+ column :note do |resource|
11
+ resource.hits.first.note.html_safe
12
+ end
13
+
14
+ column :user
15
+ column :hits do |resource|
16
+ link_to("#{resource.hits.count}", admin_visit_hits_path(resource))
16
17
  end
17
18
 
18
19
  column :user_agent
@@ -27,22 +28,29 @@ ActiveAdmin.register Visit do
27
28
 
28
29
  default_actions
29
30
  end
31
+
32
+ filter :user_username, :as => :string
33
+ filter :user_agent
34
+ filter :remote_host
35
+ filter :created_at
30
36
  end
31
37
 
32
38
  ActiveAdmin.register Hit do
33
- menu :parent => "Users"
39
+ menu false
40
+
34
41
  belongs_to :visit, :optional => true
35
42
 
36
- actions :all, :except => [:edit, :update, :create]
43
+ actions :index, :show, :destroy
37
44
 
38
45
  index do
39
46
  selectable_column
40
- column :note
41
-
42
- column :action, :sortable => :action do |resource|
43
- "#{resource.http_method} #{resource.action}"
44
- end
45
-
47
+ column "Time", :sortable => :created_at do |resource|
48
+ resource.created_at.strftime('%T %Z')
49
+ end
50
+ column :note do |resource|
51
+ resource.note.html_safe
52
+ end
53
+
46
54
  default_actions
47
55
  end
48
56
  end
@@ -20,7 +20,8 @@ module Saw
20
20
 
21
21
  visit ||= Visit.create :user_id => user_id,
22
22
  :session_id => session_id,
23
- :remote_host => remote_host
23
+ :remote_host => remote_host,
24
+ :user_agent => user_agent
24
25
 
25
26
  hit = visit.hits.build :url => url,
26
27
  :http_method => http_method,
@@ -1,3 +1,3 @@
1
1
  module Saw
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -3,7 +3,7 @@ class Visit < ActiveRecord::Base
3
3
 
4
4
  attr_accessible :user_id, :session_id, :remote_host
5
5
 
6
- has_many :hits
6
+ has_many :hits, :dependent => :destroy
7
7
  belongs_to :user
8
8
 
9
9
  def title
@@ -3,7 +3,7 @@ class Visit < ActiveRecord::Base
3
3
 
4
4
  attr_accessible :user_id, :session_id, :remote_host
5
5
 
6
- has_many :hits
6
+ has_many :hits, :dependent => :destroy
7
7
  belongs_to :user
8
8
 
9
9
  def title
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amol Pujari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-04 00:00:00.000000000 Z
11
+ date: 2013-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails