ahoy_matey 3.3.0 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +61 -62
- data/app/controllers/ahoy/base_controller.rb +12 -4
- data/app/jobs/ahoy/geocode_v2_job.rb +2 -0
- data/lib/ahoy/engine.rb +7 -0
- data/lib/ahoy/query_methods.rb +32 -63
- data/lib/ahoy/tracker.rb +1 -4
- data/lib/ahoy/version.rb +1 -1
- data/lib/ahoy.rb +3 -8
- data/lib/generators/ahoy/templates/base_store_initializer.rb.tt +2 -2
- data/lib/generators/ahoy/templates/database_store_initializer.rb.tt +2 -2
- data/vendor/assets/javascripts/ahoy.js +6 -17
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8291f7d5566895e2973be22a9dd2e4f3cd43449d1289a5d176b38eed17c9a81d
|
4
|
+
data.tar.gz: a2551e19aefafbf339f77dea16b3544ce2d3f6084372523029c5ac2b86a13260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c29a7d295c896e8191b213f877668910f6ca751d50750e1262ac41b2bedf971ec2342dc73dc9ac27d8f4e25306e83474162687bfbef8f44ea9887287adc89f57
|
7
|
+
data.tar.gz: 901f80e0995a39f63b6d4ae4f36c8a8c1b064f9820b7783d495775152c81d7310aa40efa2286398fbdf2e7108dd80bb9a6415acf44e62e5a414f71c1d0a5975c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
## 4.0.3 (2022-01-15)
|
2
|
+
|
3
|
+
- Support for `importmap-rails` is no longer experimental
|
4
|
+
- Fixed asset precompilation error with `importmap-rails`
|
5
|
+
|
6
|
+
## 4.0.2 (2021-11-06)
|
7
|
+
|
8
|
+
- Added experimental support for `importmap-rails`
|
9
|
+
|
10
|
+
## 4.0.1 (2021-08-18)
|
11
|
+
|
12
|
+
- Added support for `where_event`, `where_props`, and `where_group` for SQLite
|
13
|
+
- Fixed results with `where_event` for MySQL, MariaDB, and Postgres `hstore`
|
14
|
+
- Fixed results with `where_props` and `where_group` when used with other scopes for MySQL, MariaDB, and Postgres `hstore`
|
15
|
+
|
16
|
+
## 4.0.0 (2021-08-14)
|
17
|
+
|
18
|
+
- Disabled geocoding by default (this was already the case for new installations with 3.2.0+)
|
19
|
+
- Made the `geocoder` gem an optional dependency
|
20
|
+
- Updated Ahoy.js to 0.4.0
|
21
|
+
- Updated API to return 400 status code when missing required parameters
|
22
|
+
- Dropped support for Ruby < 2.6 and Rails < 5.2
|
23
|
+
|
1
24
|
## 3.3.0 (2021-08-13)
|
2
25
|
|
3
26
|
- Added `country_code` to geocoding
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
Track visits and events in Ruby, JavaScript, and native apps. Data is stored in your database by default, and you can customize it for any data store as you grow.
|
6
6
|
|
7
|
+
**Ahoy 4.0 was recently released** - see [how to upgrade](#upgrading)
|
8
|
+
|
7
9
|
:postbox: Check out [Ahoy Email](https://github.com/ankane/ahoy_email) for emails and [Field Test](https://github.com/ankane/field_test) for A/B testing
|
8
10
|
|
9
11
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
@@ -46,6 +48,18 @@ And restart your web server.
|
|
46
48
|
|
47
49
|
### JavaScript
|
48
50
|
|
51
|
+
For Rails 7 / Importmap, add to `config/importmap.rb`:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
pin "ahoy", to: "ahoy.js"
|
55
|
+
```
|
56
|
+
|
57
|
+
And add to `app/javascript/application.js`:
|
58
|
+
|
59
|
+
```javascript
|
60
|
+
import "ahoy"
|
61
|
+
```
|
62
|
+
|
49
63
|
For Rails 6 / Webpacker, run:
|
50
64
|
|
51
65
|
```sh
|
@@ -55,7 +69,7 @@ yarn add ahoy.js
|
|
55
69
|
And add to `app/javascript/packs/application.js`:
|
56
70
|
|
57
71
|
```javascript
|
58
|
-
import ahoy from "ahoy.js"
|
72
|
+
import ahoy from "ahoy.js"
|
59
73
|
```
|
60
74
|
|
61
75
|
For Rails 5 / Sprockets, add to `app/assets/javascripts/application.js`:
|
@@ -143,12 +157,6 @@ end
|
|
143
157
|
ahoy.track("Viewed book", {title: "The World is Flat"});
|
144
158
|
```
|
145
159
|
|
146
|
-
Track events automatically with:
|
147
|
-
|
148
|
-
```javascript
|
149
|
-
ahoy.trackAll();
|
150
|
-
```
|
151
|
-
|
152
160
|
See [Ahoy.js](https://github.com/ankane/ahoy.js) for a complete list of features.
|
153
161
|
|
154
162
|
#### Native Apps
|
@@ -350,7 +358,13 @@ Safely.report_exception_method = ->(e) { Rollbar.error(e) }
|
|
350
358
|
|
351
359
|
Ahoy uses [Geocoder](https://github.com/alexreisner/geocoder) for geocoding. We recommend configuring [local geocoding](#local-geocoding) or [load balancer geocoding](#load-balancer-geocoding) so IP addresses are not sent to a 3rd party service. If you do use a 3rd party service and adhere to GDPR, be sure to add it to your subprocessor list. If Ahoy is configured to [mask IPs](#ip-masking), the masked IP is used (this can reduce accuracy but is better for privacy).
|
352
360
|
|
353
|
-
To enable geocoding,
|
361
|
+
To enable geocoding, add this line to your application’s Gemfile:
|
362
|
+
|
363
|
+
```ruby
|
364
|
+
gem 'geocoder'
|
365
|
+
```
|
366
|
+
|
367
|
+
And update `config/initializers/ahoy.rb`:
|
354
368
|
|
355
369
|
```ruby
|
356
370
|
Ahoy.geocode = true
|
@@ -659,7 +673,7 @@ Group by properties with:
|
|
659
673
|
Ahoy::Event.group_prop(:product_id, :category).count
|
660
674
|
```
|
661
675
|
|
662
|
-
Note: MySQL and MariaDB always return string keys (
|
676
|
+
Note: MySQL and MariaDB always return string keys (including `"null"` for `nil`) for `group_prop`.
|
663
677
|
|
664
678
|
### Funnels
|
665
679
|
|
@@ -692,6 +706,24 @@ daily_visits = Ahoy::Visit.group_by_day(:started_at).count # uses Groupdate
|
|
692
706
|
Prophet.forecast(daily_visits)
|
693
707
|
```
|
694
708
|
|
709
|
+
### Anomaly Detection
|
710
|
+
|
711
|
+
To detect anomalies in visits and events, check out [AnomalyDetection.rb](https://github.com/ankane/AnomalyDetection.rb).
|
712
|
+
|
713
|
+
```ruby
|
714
|
+
daily_visits = Ahoy::Visit.group_by_day(:started_at).count # uses Groupdate
|
715
|
+
AnomalyDetection.detect(daily_visits, period: 7)
|
716
|
+
```
|
717
|
+
|
718
|
+
### Breakout Detection
|
719
|
+
|
720
|
+
To detect breakouts in visits and events, check out [Breakout](https://github.com/ankane/breakout).
|
721
|
+
|
722
|
+
```ruby
|
723
|
+
daily_visits = Ahoy::Visit.group_by_day(:started_at).count # uses Groupdate
|
724
|
+
Breakout.detect(daily_visits)
|
725
|
+
```
|
726
|
+
|
695
727
|
### Recommendations
|
696
728
|
|
697
729
|
To make recommendations based on events, check out [Disco](https://github.com/ankane/disco#ahoy).
|
@@ -743,62 +775,19 @@ Send a `POST` request to `/ahoy/events` with `Content-Type: application/json` an
|
|
743
775
|
|
744
776
|
## Upgrading
|
745
777
|
|
746
|
-
###
|
747
|
-
|
748
|
-
If you installed Ahoy before 2.1 and want to keep legacy user agent parsing and bot detection, add to your Gemfile:
|
749
|
-
|
750
|
-
```ruby
|
751
|
-
gem "browser", "~> 2.0"
|
752
|
-
gem "user_agent_parser"
|
753
|
-
```
|
754
|
-
|
755
|
-
And add to `config/initializers/ahoy.rb`:
|
756
|
-
|
757
|
-
```ruby
|
758
|
-
Ahoy.user_agent_parser = :legacy
|
759
|
-
```
|
778
|
+
### 4.0
|
760
779
|
|
761
|
-
|
780
|
+
There are two notable changes to geocoding:
|
762
781
|
|
763
|
-
|
782
|
+
1. Geocoding is now disabled by default (this was already the case for new installations with 3.2.0+). Check out the instructions for [how to enable it](#geocoding).
|
764
783
|
|
765
|
-
|
766
|
-
Ahoy.bot_detection_version = 2
|
767
|
-
```
|
784
|
+
2. The `geocoder` gem is now an optional dependency. To use geocoding, add it to your Gemfile:
|
768
785
|
|
769
|
-
|
786
|
+
```ruby
|
787
|
+
gem 'geocoder'
|
788
|
+
```
|
770
789
|
|
771
|
-
|
772
|
-
|
773
|
-
```ruby
|
774
|
-
Ahoy.user_agent_parser = :device_detector
|
775
|
-
```
|
776
|
-
|
777
|
-
Backfill existing records with:
|
778
|
-
|
779
|
-
```ruby
|
780
|
-
Ahoy::Visit.find_each do |visit|
|
781
|
-
client = DeviceDetector.new(visit.user_agent)
|
782
|
-
device_type =
|
783
|
-
case client.device_type
|
784
|
-
when "smartphone"
|
785
|
-
"Mobile"
|
786
|
-
when "tv"
|
787
|
-
"TV"
|
788
|
-
else
|
789
|
-
client.device_type.try(:titleize)
|
790
|
-
end
|
791
|
-
|
792
|
-
visit.browser = client.name
|
793
|
-
visit.os = client.os_name
|
794
|
-
visit.device_type = device_type
|
795
|
-
visit.save(validate: false) if visit.changed?
|
796
|
-
end
|
797
|
-
```
|
798
|
-
|
799
|
-
### 2.0
|
800
|
-
|
801
|
-
See the [upgrade guide](docs/Ahoy-2-Upgrade.md)
|
790
|
+
Also, check out the [upgrade notes](https://github.com/ankane/ahoy.js#upgrading) for Ahoy.js.
|
802
791
|
|
803
792
|
## History
|
804
793
|
|
@@ -822,10 +811,20 @@ bundle install
|
|
822
811
|
bundle exec rake test
|
823
812
|
```
|
824
813
|
|
825
|
-
To test query methods,
|
814
|
+
To test query methods, use:
|
826
815
|
|
827
816
|
```sh
|
817
|
+
# Postgres
|
828
818
|
createdb ahoy_test
|
819
|
+
bundle exec rake test:query_methods:postgresql
|
820
|
+
|
821
|
+
# SQLite
|
822
|
+
bundle exec rake test:query_methods:sqlite
|
823
|
+
|
824
|
+
# MySQL and MariaDB
|
829
825
|
mysqladmin create ahoy_test
|
830
|
-
bundle exec rake test:query_methods
|
826
|
+
bundle exec rake test:query_methods:mysql
|
827
|
+
|
828
|
+
# MongoDB
|
829
|
+
bundle exec rake test:query_methods:mongoid
|
831
830
|
```
|
@@ -5,19 +5,27 @@ module Ahoy
|
|
5
5
|
skip_after_action(*filters, raise: false)
|
6
6
|
skip_around_action(*filters, raise: false)
|
7
7
|
|
8
|
-
before_action :verify_request_size
|
9
|
-
before_action :renew_cookies
|
10
|
-
|
11
8
|
if respond_to?(:protect_from_forgery)
|
12
9
|
protect_from_forgery with: :null_session, if: -> { Ahoy.protect_from_forgery }
|
13
10
|
end
|
14
11
|
|
12
|
+
before_action :verify_request_size
|
13
|
+
before_action :check_params
|
14
|
+
before_action :renew_cookies
|
15
|
+
|
15
16
|
protected
|
16
17
|
|
17
18
|
def ahoy
|
18
19
|
@ahoy ||= Ahoy::Tracker.new(controller: self, api: true)
|
19
20
|
end
|
20
21
|
|
22
|
+
def check_params
|
23
|
+
if ahoy.send(:missing_params?)
|
24
|
+
logger.info "[ahoy] Missing required parameters"
|
25
|
+
render plain: "Missing required parameters\n", status: :bad_request
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
# set proper ttl if cookie generated from JavaScript
|
22
30
|
# approach is not perfect, as user must reload the page
|
23
31
|
# for new cookie settings to take effect
|
@@ -28,7 +36,7 @@ module Ahoy
|
|
28
36
|
def verify_request_size
|
29
37
|
if request.content_length > Ahoy.max_content_length
|
30
38
|
logger.info "[ahoy] Payload too large"
|
31
|
-
render plain: "Payload too large\n", status:
|
39
|
+
render plain: "Payload too large\n", status: :payload_too_large
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
data/lib/ahoy/engine.rb
CHANGED
data/lib/ahoy/query_methods.rb
CHANGED
@@ -8,64 +8,40 @@ module Ahoy
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def where_props(properties)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
adapter_name = connection.adapter_name.downcase
|
15
|
-
else
|
16
|
-
adapter_name = "mongoid"
|
17
|
-
end
|
11
|
+
return all if properties.empty?
|
12
|
+
|
13
|
+
adapter_name = respond_to?(:connection) ? connection.adapter_name.downcase : "mongoid"
|
18
14
|
case adapter_name
|
19
15
|
when "mongoid"
|
20
|
-
|
16
|
+
where(properties.to_h { |k, v| ["properties.#{k}", v] })
|
21
17
|
when /mysql/
|
22
|
-
|
23
|
-
|
18
|
+
where("JSON_CONTAINS(properties, ?, '$') = 1", properties.to_json)
|
19
|
+
when /postgres|postgis/
|
20
|
+
case columns_hash["properties"].type
|
21
|
+
when :hstore
|
22
|
+
properties.inject(all) do |relation, (k, v)|
|
24
23
|
if v.nil?
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
relation.where("properties -> ? IS NULL", k.to_s)
|
25
|
+
else
|
26
|
+
relation.where("properties -> ? = ?", k.to_s, v.to_s)
|
28
27
|
end
|
29
|
-
|
30
|
-
relation = relation.where("JSON_UNQUOTE(properties -> ?) = ?", "$.#{k}", v.as_json)
|
31
28
|
end
|
29
|
+
when :jsonb
|
30
|
+
where("properties @> ?", properties.to_json)
|
32
31
|
else
|
33
|
-
properties
|
34
|
-
# TODO cast to json instead
|
35
|
-
relation = relation.where("properties REGEXP ?", "[{,]#{{k.to_s => v}.to_json.sub(/\A\{/, "").sub(/\}\z/, "").gsub("+", "\\\\+")}[,}]")
|
36
|
-
end
|
32
|
+
where("properties::jsonb @> ?", properties.to_json)
|
37
33
|
end
|
38
|
-
when /
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
relation =
|
44
|
-
if v.nil?
|
45
|
-
relation.where("properties ->> ? IS NULL", k.to_s)
|
46
|
-
else
|
47
|
-
relation.where("properties ->> ? = ?", k.to_s, v.as_json.to_s)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
elsif column_type == :hstore
|
51
|
-
properties.each do |k, v|
|
52
|
-
relation =
|
53
|
-
if v.nil?
|
54
|
-
relation.where("properties -> ? IS NULL", k.to_s)
|
55
|
-
else
|
56
|
-
relation.where("properties -> ? = ?", k.to_s, v.to_s)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
else
|
60
|
-
properties.each do |k, v|
|
61
|
-
# TODO cast to jsonb instead
|
62
|
-
relation = relation.where("properties SIMILAR TO ?", "%[{,]#{{k.to_s => v}.to_json.sub(/\A\{/, "").sub(/\}\z/, "").gsub("+", "\\\\+")}[,}]%")
|
34
|
+
when /sqlite/
|
35
|
+
properties.inject(all) do |relation, (k, v)|
|
36
|
+
if v.nil?
|
37
|
+
relation.where("JSON_EXTRACT(properties, ?) IS NULL", "$.#{k}")
|
38
|
+
else
|
39
|
+
relation.where("JSON_EXTRACT(properties, ?) = ?", "$.#{k}", v.as_json)
|
63
40
|
end
|
64
41
|
end
|
65
42
|
else
|
66
43
|
raise "Adapter not supported: #{adapter_name}"
|
67
44
|
end
|
68
|
-
relation
|
69
45
|
end
|
70
46
|
alias_method :where_properties, :where_props
|
71
47
|
|
@@ -73,39 +49,32 @@ module Ahoy
|
|
73
49
|
# like with group
|
74
50
|
props.flatten!
|
75
51
|
|
76
|
-
relation =
|
77
|
-
|
78
|
-
column_type = columns_hash["properties"].type
|
79
|
-
adapter_name = connection.adapter_name.downcase
|
80
|
-
else
|
81
|
-
adapter_name = "mongoid"
|
82
|
-
end
|
52
|
+
relation = all
|
53
|
+
adapter_name = respond_to?(:connection) ? connection.adapter_name.downcase : "mongoid"
|
83
54
|
case adapter_name
|
84
55
|
when "mongoid"
|
85
56
|
raise "Adapter not supported: #{adapter_name}"
|
86
57
|
when /mysql/
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
relation = relation.group("JSON_UNQUOTE(JSON_EXTRACT(properties, #{quoted_prop}))")
|
91
|
-
end
|
92
|
-
else
|
93
|
-
column = column_type == :json ? "properties" : "CAST(properties AS JSON)"
|
94
|
-
props.each do |prop|
|
95
|
-
quoted_prop = connection.quote("$.#{prop}")
|
96
|
-
relation = relation.group("JSON_UNQUOTE(JSON_EXTRACT(#{column}, #{quoted_prop}))")
|
97
|
-
end
|
58
|
+
props.each do |prop|
|
59
|
+
quoted_prop = connection.quote("$.#{prop}")
|
60
|
+
relation = relation.group("JSON_UNQUOTE(JSON_EXTRACT(properties, #{quoted_prop}))")
|
98
61
|
end
|
99
62
|
when /postgres|postgis/
|
100
63
|
# convert to jsonb to fix
|
101
64
|
# could not identify an equality operator for type json
|
102
65
|
# and for text columns
|
66
|
+
column_type = columns_hash["properties"].type
|
103
67
|
cast = [:jsonb, :hstore].include?(column_type) ? "" : "::jsonb"
|
104
68
|
|
105
69
|
props.each do |prop|
|
106
70
|
quoted_prop = connection.quote(prop)
|
107
71
|
relation = relation.group("properties#{cast} -> #{quoted_prop}")
|
108
72
|
end
|
73
|
+
when /sqlite/
|
74
|
+
props.each do |prop|
|
75
|
+
quoted_prop = connection.quote("$.#{prop}")
|
76
|
+
relation = relation.group("JSON_EXTRACT(properties, #{quoted_prop})")
|
77
|
+
end
|
109
78
|
else
|
110
79
|
raise "Adapter not supported: #{adapter_name}"
|
111
80
|
end
|
data/lib/ahoy/tracker.rb
CHANGED
@@ -19,8 +19,6 @@ module Ahoy
|
|
19
19
|
def track(name, properties = {}, options = {})
|
20
20
|
if exclude?
|
21
21
|
debug "Event excluded"
|
22
|
-
elsif missing_params?
|
23
|
-
debug "Missing required parameters"
|
24
22
|
else
|
25
23
|
data = {
|
26
24
|
visit_token: visit_token,
|
@@ -41,8 +39,6 @@ module Ahoy
|
|
41
39
|
def track_visit(defer: false, started_at: nil)
|
42
40
|
if exclude?
|
43
41
|
debug "Visit excluded"
|
44
|
-
elsif missing_params?
|
45
|
-
debug "Missing required parameters"
|
46
42
|
else
|
47
43
|
if defer
|
48
44
|
set_cookie("ahoy_track", true, nil, false)
|
@@ -155,6 +151,7 @@ module Ahoy
|
|
155
151
|
@options[:api]
|
156
152
|
end
|
157
153
|
|
154
|
+
# private, but used by API
|
158
155
|
def missing_params?
|
159
156
|
if Ahoy.cookies && api? && Ahoy.protect_from_forgery
|
160
157
|
!(existing_visit_token && existing_visitor_token)
|
data/lib/ahoy/version.rb
CHANGED
data/lib/ahoy.rb
CHANGED
@@ -4,7 +4,6 @@ require "ipaddr"
|
|
4
4
|
# dependencies
|
5
5
|
require "active_support"
|
6
6
|
require "active_support/core_ext"
|
7
|
-
require "geocoder"
|
8
7
|
require "safely/core"
|
9
8
|
|
10
9
|
# modules
|
@@ -44,7 +43,7 @@ module Ahoy
|
|
44
43
|
self.quiet = true
|
45
44
|
|
46
45
|
mattr_accessor :geocode
|
47
|
-
self.geocode =
|
46
|
+
self.geocode = false
|
48
47
|
|
49
48
|
mattr_accessor :max_content_length
|
50
49
|
self.max_content_length = 8192
|
@@ -128,10 +127,6 @@ ActiveSupport.on_load(:action_view) do
|
|
128
127
|
end
|
129
128
|
|
130
129
|
# Mongoid
|
131
|
-
|
132
|
-
|
133
|
-
# Mongoid::Document::ClassMethods.include(Ahoy::Model)
|
134
|
-
# end
|
135
|
-
if defined?(ActiveModel)
|
136
|
-
ActiveModel::Callbacks.include(Ahoy::Model)
|
130
|
+
ActiveSupport.on_load(:mongoid) do
|
131
|
+
Mongoid::Document::ClassMethods.include(Ahoy::Model)
|
137
132
|
end
|
@@ -19,7 +19,7 @@ end
|
|
19
19
|
# set to true for JavaScript tracking
|
20
20
|
Ahoy.api = false
|
21
21
|
|
22
|
-
# set to true for geocoding
|
23
|
-
# we recommend configuring local geocoding
|
22
|
+
# set to true for geocoding (and add the geocoder gem to your Gemfile)
|
23
|
+
# we recommend configuring local geocoding as well
|
24
24
|
# see https://github.com/ankane/ahoy#geocoding
|
25
25
|
Ahoy.geocode = false
|
@@ -4,7 +4,7 @@ end
|
|
4
4
|
# set to true for JavaScript tracking
|
5
5
|
Ahoy.api = false
|
6
6
|
|
7
|
-
# set to true for geocoding
|
8
|
-
# we recommend configuring local geocoding
|
7
|
+
# set to true for geocoding (and add the geocoder gem to your Gemfile)
|
8
|
+
# we recommend configuring local geocoding as well
|
9
9
|
# see https://github.com/ankane/ahoy#geocoding
|
10
10
|
Ahoy.geocode = false
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* Ahoy.js
|
3
3
|
* Simple, powerful JavaScript analytics
|
4
4
|
* https://github.com/ankane/ahoy.js
|
5
|
-
* v0.
|
5
|
+
* v0.4.0
|
6
6
|
* MIT License
|
7
7
|
*/
|
8
8
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
if (domain) {
|
27
27
|
cookieDomain = "; domain=" + domain;
|
28
28
|
}
|
29
|
-
document.cookie = name + "=" + escape(value) + expires + cookieDomain + "; path
|
29
|
+
document.cookie = name + "=" + escape(value) + expires + cookieDomain + "; path=/; samesite=lax";
|
30
30
|
},
|
31
31
|
get: function (name) {
|
32
32
|
var i, c;
|
@@ -478,8 +478,7 @@
|
|
478
478
|
|
479
479
|
ahoy.trackClicks = function (selector) {
|
480
480
|
if (selector === undefined) {
|
481
|
-
|
482
|
-
selector = "a, button, input[type=submit]";
|
481
|
+
throw new Error("Missing selector");
|
483
482
|
}
|
484
483
|
onEvent("click", selector, function (e) {
|
485
484
|
var properties = eventProperties.call(this, e);
|
@@ -491,8 +490,7 @@
|
|
491
490
|
|
492
491
|
ahoy.trackSubmits = function (selector) {
|
493
492
|
if (selector === undefined) {
|
494
|
-
|
495
|
-
selector = "form";
|
493
|
+
throw new Error("Missing selector");
|
496
494
|
}
|
497
495
|
onEvent("submit", selector, function (e) {
|
498
496
|
var properties = eventProperties.call(this, e);
|
@@ -501,10 +499,9 @@
|
|
501
499
|
};
|
502
500
|
|
503
501
|
ahoy.trackChanges = function (selector) {
|
502
|
+
log("trackChanges is deprecated and will be removed in 0.5.0");
|
504
503
|
if (selector === undefined) {
|
505
|
-
|
506
|
-
log("trackChanges is deprecated and will be removed in 0.4.0");
|
507
|
-
selector = "input, textarea, select";
|
504
|
+
throw new Error("Missing selector");
|
508
505
|
}
|
509
506
|
onEvent("change", selector, function (e) {
|
510
507
|
var properties = eventProperties.call(this, e);
|
@@ -512,14 +509,6 @@
|
|
512
509
|
});
|
513
510
|
};
|
514
511
|
|
515
|
-
ahoy.trackAll = function() {
|
516
|
-
log("trackAll is deprecated and will be removed in 0.4.0");
|
517
|
-
ahoy.trackView();
|
518
|
-
ahoy.trackClicks("a, button, input[type=submit]");
|
519
|
-
ahoy.trackSubmits("form");
|
520
|
-
ahoy.trackChanges("input, textarea, select");
|
521
|
-
};
|
522
|
-
|
523
512
|
// push events from queue
|
524
513
|
try {
|
525
514
|
eventQueue = JSON.parse(getCookie("ahoy_events") || "[]");
|
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:
|
4
|
+
version: 4.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5'
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: geocoder
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.4.5
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.4.5
|
26
|
+
version: '5.2'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: safely_block
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,14 +106,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
106
|
requirements:
|
121
107
|
- - ">="
|
122
108
|
- !ruby/object:Gem::Version
|
123
|
-
version: '2.
|
109
|
+
version: '2.6'
|
124
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
111
|
requirements:
|
126
112
|
- - ">="
|
127
113
|
- !ruby/object:Gem::Version
|
128
114
|
version: '0'
|
129
115
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.3.3
|
131
117
|
signing_key:
|
132
118
|
specification_version: 4
|
133
119
|
summary: Simple, powerful, first-party analytics for Rails
|