ahoy_matey 5.2.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +7 -7
- data/lib/ahoy/engine.rb +1 -1
- data/lib/ahoy/query_methods.rb +11 -11
- data/lib/ahoy/version.rb +1 -1
- metadata +6 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba34513817526ee22ee090db462d8e11168d98ec27cbbb3a866fd8ec29a388c3
|
4
|
+
data.tar.gz: 5acf5aaf4ea4339cc097b24ee3c4cdd5c09dd3f7a1eb080917d534314f74f102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e5ca2c125b06888e40b16859b3bd5d5a2f547fcd1a6eea4d53110ba8432925d1ef77b09817e2f9b4383307801ab23e9d74fc85dfef747014830d6c1b4563f2d
|
7
|
+
data.tar.gz: 030df3974b1b106e8a57eeffe9d92662b3d59b9486901342e67e3b2f352ef60be7bc85c1d8954fe6eaff0c8a51fada657b96f8b08fe2650d0f20965f7f671738
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 5.3.0 (2025-02-01)
|
2
|
+
|
3
|
+
- Dropped support for Ruby < 3.1 and Rails < 7
|
4
|
+
- Dropped support for Mongoid < 8
|
5
|
+
|
6
|
+
## 5.2.1 (2024-10-07)
|
7
|
+
|
8
|
+
- Fixed connection leasing for Active Record 7.2+
|
9
|
+
|
1
10
|
## 5.2.0 (2024-09-04)
|
2
11
|
|
3
12
|
- Improved error handling for invalid API parameters
|
@@ -358,3 +367,19 @@ Breaking changes
|
|
358
367
|
## 0.1.0 (2014-03-19)
|
359
368
|
|
360
369
|
- First major release
|
370
|
+
|
371
|
+
## 0.0.4 (2014-03-01)
|
372
|
+
|
373
|
+
- Added UTM parameters
|
374
|
+
|
375
|
+
## 0.0.3 (2014-02-26)
|
376
|
+
|
377
|
+
- Renamed `ahoy_visit` method to `current_visit`
|
378
|
+
|
379
|
+
## 0.0.2 (2014-02-26)
|
380
|
+
|
381
|
+
- Added `ahoy_visit` method to controllers
|
382
|
+
|
383
|
+
## 0.0.1 (2014-02-26)
|
384
|
+
|
385
|
+
- First release
|
data/README.md
CHANGED
@@ -4,8 +4,6 @@
|
|
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 5.0 was recently released** - see [how to upgrade](#upgrading)
|
8
|
-
|
9
7
|
: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
|
10
8
|
|
11
9
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
@@ -48,7 +46,7 @@ And restart your web server.
|
|
48
46
|
|
49
47
|
### JavaScript
|
50
48
|
|
51
|
-
For Importmap (Rails 7 default), add to `config/importmap.rb`:
|
49
|
+
For Importmap (Rails 7+ default), add to `config/importmap.rb`:
|
52
50
|
|
53
51
|
```ruby
|
54
52
|
pin "ahoy", to: "ahoy.js"
|
@@ -60,13 +58,15 @@ And add to `app/javascript/application.js`:
|
|
60
58
|
import "ahoy"
|
61
59
|
```
|
62
60
|
|
63
|
-
For
|
61
|
+
For Bun, esbuild, rollup.js, or Webpack, run:
|
64
62
|
|
65
63
|
```sh
|
64
|
+
bun add ahoy.js
|
65
|
+
# or
|
66
66
|
yarn add ahoy.js
|
67
67
|
```
|
68
68
|
|
69
|
-
And add to `app/javascript/
|
69
|
+
And add to `app/javascript/application.js`:
|
70
70
|
|
71
71
|
```javascript
|
72
72
|
import ahoy from "ahoy.js"
|
@@ -197,7 +197,7 @@ 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 AddAhoyVisitToOrders < ActiveRecord::Migration[
|
200
|
+
class AddAhoyVisitToOrders < ActiveRecord::Migration[8.0]
|
201
201
|
def change
|
202
202
|
add_reference :orders, :ahoy_visit
|
203
203
|
end
|
@@ -765,7 +765,7 @@ Send a `POST` request to `/ahoy/events` with `Content-Type: application/json` an
|
|
765
765
|
"properties": {
|
766
766
|
"item_id": 123
|
767
767
|
},
|
768
|
-
"time": "
|
768
|
+
"time": "2025-01-01T00:00:00-07:00"
|
769
769
|
}
|
770
770
|
]
|
771
771
|
}
|
data/lib/ahoy/engine.rb
CHANGED
data/lib/ahoy/query_methods.rb
CHANGED
@@ -10,13 +10,13 @@ module Ahoy
|
|
10
10
|
def where_props(properties)
|
11
11
|
return all if properties.empty?
|
12
12
|
|
13
|
-
adapter_name = respond_to?(:
|
13
|
+
adapter_name = respond_to?(:connection_db_config) ? connection_db_config.adapter.to_s : "mongoid"
|
14
14
|
case adapter_name
|
15
15
|
when "mongoid"
|
16
16
|
where(properties.to_h { |k, v| ["properties.#{k}", v] })
|
17
|
-
when /mysql|trilogy/
|
17
|
+
when /mysql|trilogy/i
|
18
18
|
where("JSON_CONTAINS(properties, ?, '$') = 1", properties.to_json)
|
19
|
-
when /
|
19
|
+
when /postg/i
|
20
20
|
case columns_hash["properties"].type
|
21
21
|
when :hstore
|
22
22
|
properties.inject(all) do |relation, (k, v)|
|
@@ -31,7 +31,7 @@ module Ahoy
|
|
31
31
|
else
|
32
32
|
where("properties::jsonb @> ?", properties.to_json)
|
33
33
|
end
|
34
|
-
when /sqlite/
|
34
|
+
when /sqlite/i
|
35
35
|
properties.inject(all) do |relation, (k, v)|
|
36
36
|
if v.nil?
|
37
37
|
relation.where("JSON_EXTRACT(properties, ?) IS NULL", "$.#{k}")
|
@@ -50,16 +50,16 @@ module Ahoy
|
|
50
50
|
props.flatten!
|
51
51
|
|
52
52
|
relation = all
|
53
|
-
adapter_name = respond_to?(:
|
53
|
+
adapter_name = respond_to?(:connection_db_config) ? connection_db_config.adapter.to_s : "mongoid"
|
54
54
|
case adapter_name
|
55
55
|
when "mongoid"
|
56
56
|
raise "Adapter not supported: #{adapter_name}"
|
57
|
-
when /mysql|trilogy/
|
57
|
+
when /mysql|trilogy/i
|
58
58
|
props.each do |prop|
|
59
|
-
quoted_prop =
|
59
|
+
quoted_prop = connection_pool.with_connection { |c| c.quote("$.#{prop}") }
|
60
60
|
relation = relation.group("JSON_UNQUOTE(JSON_EXTRACT(properties, #{quoted_prop}))")
|
61
61
|
end
|
62
|
-
when /
|
62
|
+
when /postg/i
|
63
63
|
# convert to jsonb to fix
|
64
64
|
# could not identify an equality operator for type json
|
65
65
|
# and for text columns
|
@@ -67,12 +67,12 @@ module Ahoy
|
|
67
67
|
cast = [:jsonb, :hstore].include?(column_type) ? "" : "::jsonb"
|
68
68
|
|
69
69
|
props.each do |prop|
|
70
|
-
quoted_prop =
|
70
|
+
quoted_prop = connection_pool.with_connection { |c| c.quote(prop) }
|
71
71
|
relation = relation.group("properties#{cast} -> #{quoted_prop}")
|
72
72
|
end
|
73
|
-
when /sqlite/
|
73
|
+
when /sqlite/i
|
74
74
|
props.each do |prop|
|
75
|
-
quoted_prop =
|
75
|
+
quoted_prop = connection_pool.with_connection { |c| c.quote("$.#{prop}") }
|
76
76
|
relation = relation.group("JSON_EXTRACT(properties, #{quoted_prop})")
|
77
77
|
end
|
78
78
|
else
|
data/lib/ahoy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_matey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-01 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -16,14 +15,14 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '7'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
25
|
+
version: '7'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: device_detector
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +51,6 @@ dependencies:
|
|
52
51
|
- - ">="
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: '0.4'
|
55
|
-
description:
|
56
54
|
email: andrew@ankane.org
|
57
55
|
executables: []
|
58
56
|
extensions: []
|
@@ -97,7 +95,6 @@ homepage: https://github.com/ankane/ahoy
|
|
97
95
|
licenses:
|
98
96
|
- MIT
|
99
97
|
metadata: {}
|
100
|
-
post_install_message:
|
101
98
|
rdoc_options: []
|
102
99
|
require_paths:
|
103
100
|
- lib
|
@@ -105,15 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
102
|
requirements:
|
106
103
|
- - ">="
|
107
104
|
- !ruby/object:Gem::Version
|
108
|
-
version: '3'
|
105
|
+
version: '3.1'
|
109
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
107
|
requirements:
|
111
108
|
- - ">="
|
112
109
|
- !ruby/object:Gem::Version
|
113
110
|
version: '0'
|
114
111
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
116
|
-
signing_key:
|
112
|
+
rubygems_version: 3.6.2
|
117
113
|
specification_version: 4
|
118
114
|
summary: Simple, powerful, first-party analytics for Rails
|
119
115
|
test_files: []
|