ahoy_matey 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +52 -32
- data/lib/ahoy/model.rb +1 -1
- data/lib/ahoy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e588efc9bc71536e8077c79e1b874db35333d92
|
4
|
+
data.tar.gz: 1c97d1fc30240204a78519d8a3866e68351d40b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e448cfa2434da5e946fc7be76dcb0b626f70301828c2fa21fb19ea94e7d2e0d0faeb6d1b140159e9ee4e0de8a805322650d78fe41bf456d3698adc13ccc3e117
|
7
|
+
data.tar.gz: 795e1ecfb5d87235bd9e3fd66e0714afbda91b9e8ace354509345b12aa62e98e88379874263348b3f96464d18620d8c5db137542716e36e37345df0cfa168aa2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Ahoy
|
2
2
|
|
3
|
-
|
3
|
+
Ahoy provides a solid foundation to track visits and events in Ruby, JavaScript, and native apps.
|
4
4
|
|
5
|
-
|
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
|
-
###
|
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
|
-
|
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
|
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::
|
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
|
-
|
160
|
+
Exclude visits and events from being tracked with:
|
161
161
|
|
162
162
|
```ruby
|
163
|
-
|
164
|
-
|
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
|
-
|
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
|
-
|
179
|
+
def track_visit(options)
|
180
|
+
super do |visit|
|
181
|
+
visit.gclid = visit_properties.landing_params["gclid"]
|
182
|
+
end
|
183
|
+
end
|
179
184
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
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
|
-
|
192
|
-
|
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
|
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
|
-
|
204
|
-
|
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
|
-
|
214
|
-
|
215
|
-
|
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
data/lib/ahoy/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|