ahoy_matey 4.0.2 → 4.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06e00a470a12c20b510cc9f1476e39c2cfd8ec24115b29d5d09489d091465b74
4
- data.tar.gz: e19501a6019c94bafc32121122e2832152adb0fe8475cb3b91ed4d50c791ff6e
3
+ metadata.gz: 021c0b07d7cddf6a22125683bb5b1d18a078f1ff1f504cca066d4069c6014357
4
+ data.tar.gz: d49b52ce94f4c7436df4d054324639f9e5cd951fe459a11ca28aaab36231bd19
5
5
  SHA512:
6
- metadata.gz: b0fe7c188d2165aae96a6a5d2def6658bcf41158477d5d9aa79448b889f87c3b88ef3f6aee19309c56af3587110fff71bfcd60fae0a46562e87e1a22ae070073
7
- data.tar.gz: 285deb63fb81a4cc423c3eab394e324d5ebe8572c5500750cefe88d615bbd869228d04a725f62cde2868730d7dbd345d3d3787bbaf0acb75f04aa2e231669a81
6
+ metadata.gz: 6082fea0363bb2f25b7309876a36a1982894d3dcc2dc905da2278ab0ca41257f1c322001c86deb36168dbd1649c87199ec65990c9e7307b407b3f96fdb7a2bac
7
+ data.tar.gz: d833375e6cdb800b51072ed3d3c269e55c21c06287cde4a351022c331b36dd4b9aa812afa7b33156ee7a7b745d08a53b0d726000a919fd616300c0f6149a51b4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 4.1.0 (2022-06-12)
2
+
3
+ - Ensure `exclude_method` is only called once per request
4
+ - Fixed error with Mongoid when `Mongoid.raise_not_found_error` is `true`
5
+ - Fixed association for Mongoid
6
+
7
+ ## 4.0.3 (2022-01-15)
8
+
9
+ - Support for `importmap-rails` is no longer experimental
10
+ - Fixed asset precompilation error with `importmap-rails`
11
+
1
12
  ## 4.0.2 (2021-11-06)
2
13
 
3
14
  - Added experimental support for `importmap-rails`
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2021 Andrew Kane
1
+ Copyright (c) 2014-2022 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -17,7 +17,7 @@ Track visits and events in Ruby, JavaScript, and native apps. Data is stored in
17
17
  Add this line to your application’s Gemfile:
18
18
 
19
19
  ```ruby
20
- gem 'ahoy_matey'
20
+ gem "ahoy_matey"
21
21
  ```
22
22
 
23
23
  And run:
@@ -48,6 +48,18 @@ And restart your web server.
48
48
 
49
49
  ### JavaScript
50
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
+
51
63
  For Rails 6 / Webpacker, run:
52
64
 
53
65
  ```sh
@@ -66,18 +78,6 @@ For Rails 5 / Sprockets, add to `app/assets/javascripts/application.js`:
66
78
  //= require ahoy
67
79
  ```
68
80
 
69
- For Rails 7 / Importmap (experimental), add to `config/importmap.rb`:
70
-
71
- ```ruby
72
- pin "ahoy", to: "ahoy.js"
73
- ```
74
-
75
- And add to `app/javascript/application.js`:
76
-
77
- ```javascript
78
- import "ahoy"
79
- ```
80
-
81
81
  Track an event with:
82
82
 
83
83
  ```javascript
@@ -197,9 +197,9 @@ Order.joins(:ahoy_visit).group("device_type").count
197
197
  Here’s what the migration to add the `ahoy_visit_id` column should look like:
198
198
 
199
199
  ```ruby
200
- class AddVisitIdToOrders < ActiveRecord::Migration[6.1]
200
+ class AddAhoyVisitToOrders < ActiveRecord::Migration[7.0]
201
201
  def change
202
- add_column :orders, :ahoy_visit_id, :bigint
202
+ add_reference :orders, :ahoy_visit
203
203
  end
204
204
  end
205
205
  ```
@@ -361,7 +361,7 @@ Ahoy uses [Geocoder](https://github.com/alexreisner/geocoder) for geocoding. We
361
361
  To enable geocoding, add this line to your application’s Gemfile:
362
362
 
363
363
  ```ruby
364
- gem 'geocoder'
364
+ gem "geocoder"
365
365
  ```
366
366
 
367
367
  And update `config/initializers/ahoy.rb`:
@@ -381,7 +381,7 @@ Ahoy.job_queue = :low_priority
381
381
  For privacy and performance, we recommend geocoding locally. Add this line to your application’s Gemfile:
382
382
 
383
383
  ```ruby
384
- gem 'maxminddb'
384
+ gem "maxminddb"
385
385
  ```
386
386
 
387
387
  For city-level geocoding, download the [GeoLite2 City database](https://dev.maxmind.com/geoip/geoip2/geolite2/) and create `config/initializers/geocoder.rb` with:
@@ -500,6 +500,8 @@ Previously set cookies are automatically deleted. If you use JavaScript tracking
500
500
  ahoy.configure({cookies: false});
501
501
  ```
502
502
 
503
+ Note: With anonymity sets, visits no longer expire after 4 hours of inactivity. A new visit is only created when the IP mask or user agent changes (for instance, when a user updates their browser). There are plans to address this in the next major version.
504
+
503
505
  ## Data Retention
504
506
 
505
507
  Data should only be retained for as long as it’s needed. Delete older data with:
@@ -784,7 +786,7 @@ There are two notable changes to geocoding:
784
786
  2. The `geocoder` gem is now an optional dependency. To use geocoding, add it to your Gemfile:
785
787
 
786
788
  ```ruby
787
- gem 'geocoder'
789
+ gem "geocoder"
788
790
  ```
789
791
 
790
792
  Also, check out the [upgrade notes](https://github.com/ankane/ahoy.js#upgrading) for Ahoy.js.
@@ -811,6 +813,12 @@ bundle install
811
813
  bundle exec rake test
812
814
  ```
813
815
 
816
+ To test Mongoid, use:
817
+
818
+ ```sh
819
+ ADAPTER=mongoid bundle exec rake test
820
+ ```
821
+
814
822
  To test query methods, use:
815
823
 
816
824
  ```sh
@@ -1,4 +1,5 @@
1
1
  # for smooth update from Ahoy 1 -> 2
2
+ # TODO remove in 5.0
2
3
  module Ahoy
3
4
  class GeocodeJob < ActiveJob::Base
4
5
  queue_as { Ahoy.job_queue }
@@ -53,7 +53,12 @@ module Ahoy
53
53
 
54
54
  def visit
55
55
  unless defined?(@visit)
56
- @visit = visit_model.find_by(visit_token: ahoy.visit_token) if ahoy.visit_token
56
+ if defined?(Mongoid::Document) && visit_model < Mongoid::Document
57
+ # find_by raises error by default when not found
58
+ @visit = visit_model.where(visit_token: ahoy.visit_token).first if ahoy.visit_token
59
+ else
60
+ @visit = visit_model.find_by(visit_token: ahoy.visit_token) if ahoy.visit_token
61
+ end
57
62
  end
58
63
  @visit
59
64
  end
data/lib/ahoy/engine.rb CHANGED
@@ -28,8 +28,8 @@ module Ahoy
28
28
  end
29
29
 
30
30
  # for importmap
31
- if defined?(Importmap)
32
- initializer "ahoy.importmap", after: "importmap" do |app|
31
+ initializer "ahoy.importmap" do |app|
32
+ if defined?(Importmap)
33
33
  app.config.assets.precompile << "ahoy.js"
34
34
  end
35
35
  end
data/lib/ahoy/tracker.rb CHANGED
@@ -185,7 +185,10 @@ module Ahoy
185
185
  end
186
186
 
187
187
  def exclude?
188
- @store.exclude?
188
+ unless defined?(@exclude)
189
+ @exclude = @store.exclude?
190
+ end
191
+ @exclude
189
192
  end
190
193
 
191
194
  def report_exception(e)
data/lib/ahoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "4.0.2"
2
+ VERSION = "4.1.0"
3
3
  end
data/lib/ahoy.rb CHANGED
@@ -126,7 +126,6 @@ ActiveSupport.on_load(:action_view) do
126
126
  include Ahoy::Helper
127
127
  end
128
128
 
129
- # Mongoid
130
129
  ActiveSupport.on_load(:mongoid) do
131
130
  Mongoid::Document::ClassMethods.include(Ahoy::Model)
132
131
  end
@@ -1,3 +1,4 @@
1
+ require "rails/generators"
1
2
  require "rails/generators/active_record"
2
3
 
3
4
  module Ahoy
@@ -2,7 +2,7 @@ class Ahoy::Event
2
2
  include Mongoid::Document
3
3
 
4
4
  # associations
5
- belongs_to :visit, index: true
5
+ belongs_to :visit, class_name: "Ahoy::Visit", index: true
6
6
  belongs_to :user, index: true, optional: true
7
7
 
8
8
  # fields
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.0.2
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-06 00:00:00.000000000 Z
11
+ date: 2022-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.2.22
116
+ rubygems_version: 3.3.7
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Simple, powerful, first-party analytics for Rails