ahoy_matey 1.0.0 → 1.0.1

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: eee3fa6c02d811dff0ae4091ab08589366949211
4
- data.tar.gz: 953da9d5b867bfb6c8abff089faa3ee06b965b0d
3
+ metadata.gz: 3e588efc9bc71536e8077c79e1b874db35333d92
4
+ data.tar.gz: 1c97d1fc30240204a78519d8a3866e68351d40b9
5
5
  SHA512:
6
- metadata.gz: 4f37f8317be93f3c5192bdbc4b79fabdfa995d97da6385ad1eeb90074ea3ef8d9d4896e7f51ad4961e63f863d6269eb0fe8b59168d632db4de83b9ab158eb0ea
7
- data.tar.gz: 402780cfd8f187c0f084562ae853678f18e43ce80b331e5820843e59b823e8733d12de0fd2d2c2413cde8ea596b9c474e36a9ec70c81f26aeb1c62f143aa1d05
6
+ metadata.gz: e448cfa2434da5e946fc7be76dcb0b626f70301828c2fa21fb19ea94e7d2e0d0faeb6d1b140159e9ee4e0de8a805322650d78fe41bf456d3698adc13ccc3e117
7
+ data.tar.gz: 795e1ecfb5d87235bd9e3fd66e0714afbda91b9e8ace354509345b12aa62e98e88379874263348b3f96464d18620d8c5db137542716e36e37345df0cfa168aa2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.1
2
+
3
+ - Fixed `visitable` outside of requests
4
+
1
5
  ## 1.0.0
2
6
 
3
7
  - Added support for any data store, and Mongoid out of the box
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Ahoy
2
2
 
3
- :fire: Simple, powerful analytics for Rails
3
+ Ahoy provides a solid foundation to track visits and events in Ruby, JavaScript, and native apps.
4
4
 
5
- Ahoy makes it easy to track visitors and users. Track visits (sessions) and events in Ruby, JavaScript, and native apps. Works with any data store so you can easily scale.
5
+ :fire: Works with any data store so you can easily scale.
6
6
 
7
7
  :postbox: To track emails, check out [Ahoy Email](https://github.com/ankane/ahoy_email).
8
8
 
@@ -25,16 +25,14 @@ And add the javascript file in `app/assets/javascripts/application.js` after jQu
25
25
 
26
26
  ## Choose a Data Store
27
27
 
28
- ### ActiveRecord
29
-
30
- #### PostgreSQL
28
+ ### PostgreSQL
31
29
 
32
30
  ```sh
33
31
  rails generate ahoy:stores:active_record -d postgresql
34
32
  rake db:migrate
35
33
  ```
36
34
 
37
- #### MySQL and SQLite
35
+ ### MySQL or SQLite
38
36
 
39
37
  Add [activeuuid](https://github.com/jashmenn/activeuuid) to your Gemfile.
40
38
 
@@ -90,6 +88,8 @@ class Ahoy::Store < Ahoy::Stores::BaseStore
90
88
  end
91
89
  ```
92
90
 
91
+ See the [ActiveRecordStore](https://github.com/ankane/ahoy/blob/master/lib/ahoy/stores/active_record_store.rb) for an example.
92
+
93
93
  ## How It Works
94
94
 
95
95
  ### Visits
@@ -101,7 +101,7 @@ When someone visits your website, Ahoy creates a visit with lots of useful infor
101
101
  - **technology** - browser, OS, and device type
102
102
  - **utm parameters** - source, medium, term, content, campaign
103
103
 
104
- Use the `current_visit` method to access it, and the `ahoy.visit_id` and `ahoy.visitor_id` methods to get the ids.
104
+ Use the `current_visit` method to access it.
105
105
 
106
106
  ### Events
107
107
 
@@ -150,58 +150,74 @@ ahoy.authenticate(user)
150
150
  Stores are built to be highly customizable.
151
151
 
152
152
  ```ruby
153
- class Ahoy::Store < Ahoy::Stores::ActiveRecord
153
+ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
154
154
  # add methods here
155
155
  end
156
156
  ```
157
157
 
158
158
  ### Exclude Bots and More
159
159
 
160
- Bots are excluded by default. To change this, use:
160
+ Exclude visits and events from being tracked with:
161
161
 
162
162
  ```ruby
163
- def exclude?
164
- bot? || request.ip == "192.168.1.1"
163
+ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
164
+
165
+ def exclude?
166
+ bot? || request.ip == "192.168.1.1"
167
+ end
168
+
165
169
  end
166
170
  ```
167
171
 
172
+ Bots are excluded by default.
173
+
168
174
  ### Track Additional Values
169
175
 
170
176
  ```ruby
171
- def track_visit(options)
172
- super do |visit|
173
- visit.gclid = visit_properties.landing_params["gclid"]
174
- end
175
- end
176
- ```
177
+ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
177
178
 
178
- or
179
+ def track_visit(options)
180
+ super do |visit|
181
+ visit.gclid = visit_properties.landing_params["gclid"]
182
+ end
183
+ end
179
184
 
180
- ```ruby
181
- def track_event(name, properties, options)
182
- super do |event|
183
- event.ip = request.ip
185
+ def track_event(name, properties, options)
186
+ super do |event|
187
+ event.ip = request.ip
188
+ end
184
189
  end
190
+
185
191
  end
186
192
  ```
187
193
 
188
194
  ### Customize User
189
195
 
196
+ If you use a method other than `current_user`, set it here:
197
+
190
198
  ```ruby
191
- def user
192
- controller.true_user
199
+ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
200
+
201
+ def user
202
+ controller.true_user
203
+ end
204
+
193
205
  end
194
206
  ```
195
207
 
196
208
  ### Report Exceptions
197
209
 
198
- Exceptions are caught by default so analytics do not break your app.
210
+ Exceptions are rescued so analytics do not break your app.
199
211
 
200
212
  To report them to a service, use:
201
213
 
202
214
  ```ruby
203
- def report_exception(e)
204
- Rollbar.report_exception(e)
215
+ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
216
+
217
+ def report_exception(e)
218
+ Rollbar.report_exception(e)
219
+ end
220
+
205
221
  end
206
222
  ```
207
223
 
@@ -210,12 +226,16 @@ end
210
226
  For ActiveRecord and Mongoid stores
211
227
 
212
228
  ```ruby
213
- def visit_model
214
- CustomVisit
215
- end
229
+ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
230
+
231
+ def visit_model
232
+ CustomVisit
233
+ end
234
+
235
+ def event_model
236
+ CustomEvent
237
+ end
216
238
 
217
- def event_model
218
- CustomEvent
219
239
  end
220
240
  ```
221
241
 
data/lib/ahoy/model.rb CHANGED
@@ -13,7 +13,7 @@ module Ahoy
13
13
  end
14
14
  class_eval %Q{
15
15
  def set_visit
16
- self.#{name} ||= RequestStore.store[:ahoy].visit
16
+ self.#{name} ||= RequestStore.store[:ahoy].try(:visit)
17
17
  end
18
18
  }
19
19
  end
data/lib/ahoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_matey
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable