ahoy_matey 3.0.0 → 3.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
  SHA256:
3
- metadata.gz: 1da649f5c85699714bff1777f3226b232f555e79ec2ece218280541bbb1264d5
4
- data.tar.gz: '0180556a4ad007b5d9df07faa327a6d53e9a2cfe1bf810cb78e9d24d6cdc060b'
3
+ metadata.gz: d90d64ae8641aa0bae1bc44acf29379a585ebbad0bbb87325380508d5a8ffcc7
4
+ data.tar.gz: 7c01ce8cbd2e92e3555479b251889d171b54be9d5c369fca51f413fdc912ab01
5
5
  SHA512:
6
- metadata.gz: e7cd93d376c86d34123c964fceb7f84ef33dc0513bfb66ac1e9da1b5654a7bed69041eb0d99477b50f87c77b5bf8e4c396e4dc8bf99b10db2699ef09fb11ecf8
7
- data.tar.gz: f11f02dbd35f36982d932d12a905d060770d9f01f4b0bdfe572002dd5a10feaa07b79b1d3eb0e2df3376f00c6fbe67bbcc29549498599bd9634e164ff04d4184
6
+ metadata.gz: fe62cce407d17f736b616f11a742fefe338cdedd2457665cb3e578bafe0bd6fbb889dd315382dcb70d563a35dd5c5e05de908c069e12d21ab92e0cee637e42d7
7
+ data.tar.gz: f399c7708f6c1071c72db3d9164ab77bd3377fdc0eab7064707fb1202b240156be03669070763bf2f13bcf0bfcac134286eb9e9f9fb988d78267c71da9603386
@@ -1,3 +1,10 @@
1
+ ## 3.0.1
2
+
3
+ - Made `Ahoy::Tracker` work outside of requests
4
+ - Fixed storage of `false` values with customized store
5
+ - Fixed error with `user_method` and `Rails::InfoController`
6
+ - Gracefully handle `ActionDispatch::RemoteIp::IpSpoofAttackError`
7
+
1
8
  ## 3.0.0
2
9
 
3
10
  - Made Device Detector the default user agent parser
data/README.md CHANGED
@@ -181,7 +181,7 @@ Order.joins(:ahoy_visit).group("device_type").count
181
181
  Here’s what the migration to add the `ahoy_visit_id` column should look like:
182
182
 
183
183
  ```ruby
184
- class AddVisitIdToOrders < ActiveRecord::Migration[5.2]
184
+ class AddVisitIdToOrders < ActiveRecord::Migration[6.0]
185
185
  def change
186
186
  add_column :orders, :ahoy_visit_id, :bigint
187
187
  end
@@ -26,7 +26,7 @@ module Ahoy
26
26
  if Ahoy.user_method.respond_to?(:call)
27
27
  Ahoy.user_method.call(controller)
28
28
  else
29
- controller.send(Ahoy.user_method)
29
+ controller.send(Ahoy.user_method) if controller.respond_to?(Ahoy.user_method, true)
30
30
  end
31
31
  end
32
32
  end
@@ -76,7 +76,7 @@ module Ahoy
76
76
 
77
77
  def slice_data(model, data)
78
78
  column_names = model.try(:column_names) || model.attribute_names
79
- data.slice(*column_names.map(&:to_sym)).select { |_, v| v }
79
+ data.slice(*column_names.map(&:to_sym)).select { |_, v| !v.nil? }
80
80
  end
81
81
 
82
82
  def unique_exception?(e)
@@ -11,6 +11,7 @@ module Ahoy
11
11
  @controller = options[:controller]
12
12
  @request = options[:request] || @controller.try(:request)
13
13
  @visit_token = options[:visit_token]
14
+ @user = options[:user]
14
15
  @options = options
15
16
  end
16
17
 
@@ -57,7 +58,7 @@ module Ahoy
57
58
 
58
59
  @store.track_visit(data)
59
60
 
60
- Ahoy::GeocodeV2Job.perform_later(visit_token, data[:ip]) if Ahoy.geocode
61
+ Ahoy::GeocodeV2Job.perform_later(visit_token, data[:ip]) if Ahoy.geocode && data[:ip]
61
62
  end
62
63
  end
63
64
  true
@@ -128,7 +129,7 @@ module Ahoy
128
129
  end
129
130
 
130
131
  def visit_properties
131
- @visit_properties ||= Ahoy::VisitProperties.new(request, api: api?).generate
132
+ @visit_properties ||= request ? Ahoy::VisitProperties.new(request, api: api?).generate : {}
132
133
  end
133
134
 
134
135
  def visit_token
@@ -168,7 +169,7 @@ module Ahoy
168
169
 
169
170
  def set_cookie(name, value, duration = nil, use_domain = true)
170
171
  # safety net
171
- return unless Ahoy.cookies
172
+ return unless Ahoy.cookies && request
172
173
 
173
174
  cookie = {
174
175
  value: value
@@ -180,7 +181,7 @@ module Ahoy
180
181
  end
181
182
 
182
183
  def delete_cookie(name)
183
- request.cookie_jar.delete(name) if request.cookie_jar[name]
184
+ request.cookie_jar.delete(name) if request && request.cookie_jar[name]
184
185
  end
185
186
 
186
187
  def trusted_time(time = nil)
@@ -196,8 +197,12 @@ module Ahoy
196
197
  end
197
198
 
198
199
  def report_exception(e)
199
- raise e if !defined?(Rails) || Rails.env.development? || Rails.env.test?
200
- Safely.report_exception(e)
200
+ if defined?(ActionDispatch::RemoteIp::IpSpoofAttackError) && e.is_a?(ActionDispatch::RemoteIp::IpSpoofAttackError)
201
+ debug "Tracking excluded due to IP spoofing"
202
+ else
203
+ raise e if !defined?(Rails) || Rails.env.development? || Rails.env.test?
204
+ Safely.report_exception(e)
205
+ end
201
206
  end
202
207
 
203
208
  def generate_id
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -1,27 +1,13 @@
1
- # taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
2
- require "rails/generators"
3
- require "rails/generators/migration"
4
- require "active_record"
5
1
  require "rails/generators/active_record"
6
2
 
7
3
  module Ahoy
8
4
  module Generators
9
5
  class ActiverecordGenerator < Rails::Generators::Base
10
- include Rails::Generators::Migration
11
- source_root File.expand_path("../templates", __FILE__)
6
+ include ActiveRecord::Generators::Migration
7
+ source_root File.join(__dir__, "templates")
12
8
 
13
9
  class_option :database, type: :string, aliases: "-d"
14
10
 
15
- # Implement the required interface for Rails::Generators::Migration.
16
- def self.next_migration_number(dirname) #:nodoc:
17
- next_migration_number = current_migration_number(dirname) + 1
18
- if ::ActiveRecord::Base.timestamped_migrations
19
- [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
20
- else
21
- "%.3d" % next_migration_number
22
- end
23
- end
24
-
25
11
  def copy_templates
26
12
  template "database_store_initializer.rb", "config/initializers/ahoy.rb"
27
13
  template "active_record_visit_model.rb", "app/models/ahoy/visit.rb"
@@ -3,7 +3,7 @@ require "rails/generators"
3
3
  module Ahoy
4
4
  module Generators
5
5
  class BaseGenerator < Rails::Generators::Base
6
- source_root File.expand_path("../templates", __FILE__)
6
+ source_root File.join(__dir__, "templates")
7
7
 
8
8
  def copy_templates
9
9
  template "base_store_initializer.rb", "config/initializers/ahoy.rb"
@@ -3,7 +3,7 @@ require "rails/generators"
3
3
  module Ahoy
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path("../templates", __FILE__)
6
+ source_root File.join(__dir__, "templates")
7
7
 
8
8
  def copy_templates
9
9
  activerecord = defined?(ActiveRecord)
@@ -3,7 +3,7 @@ require "rails/generators"
3
3
  module Ahoy
4
4
  module Generators
5
5
  class MongoidGenerator < Rails::Generators::Base
6
- source_root File.expand_path("../templates", __FILE__)
6
+ source_root File.join(__dir__, "templates")
7
7
 
8
8
  def copy_templates
9
9
  template "database_store_initializer.rb", "config/initializers/ahoy.rb"
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: 3.0.0
4
+ version: 3.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: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2019-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -109,7 +109,35 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: activerecord
112
+ name: combustion
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sqlite3
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="