ahoy_matey 4.0.3 → 4.1.0

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
  SHA256:
3
- metadata.gz: 8291f7d5566895e2973be22a9dd2e4f3cd43449d1289a5d176b38eed17c9a81d
4
- data.tar.gz: a2551e19aefafbf339f77dea16b3544ce2d3f6084372523029c5ac2b86a13260
3
+ metadata.gz: 021c0b07d7cddf6a22125683bb5b1d18a078f1ff1f504cca066d4069c6014357
4
+ data.tar.gz: d49b52ce94f4c7436df4d054324639f9e5cd951fe459a11ca28aaab36231bd19
5
5
  SHA512:
6
- metadata.gz: c29a7d295c896e8191b213f877668910f6ca751d50750e1262ac41b2bedf971ec2342dc73dc9ac27d8f4e25306e83474162687bfbef8f44ea9887287adc89f57
7
- data.tar.gz: 901f80e0995a39f63b6d4ae4f36c8a8c1b064f9820b7783d495775152c81d7310aa40efa2286398fbdf2e7108dd80bb9a6415acf44e62e5a414f71c1d0a5975c
6
+ metadata.gz: 6082fea0363bb2f25b7309876a36a1982894d3dcc2dc905da2278ab0ca41257f1c322001c86deb36168dbd1649c87199ec65990c9e7307b407b3f96fdb7a2bac
7
+ data.tar.gz: d833375e6cdb800b51072ed3d3c269e55c21c06287cde4a351022c331b36dd4b9aa812afa7b33156ee7a7b745d08a53b0d726000a919fd616300c0f6149a51b4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
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
+
1
7
  ## 4.0.3 (2022-01-15)
2
8
 
3
9
  - Support for `importmap-rails` is no longer experimental
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:
@@ -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/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.3"
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.3
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: 2022-01-15 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.3.3
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