ahoy_email 2.3.1 → 2.4.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 +18 -1
- data/README.md +12 -2
- data/app/controllers/ahoy/messages_controller.rb +1 -1
- data/lib/ahoy_email/mailer.rb +3 -0
- data/lib/ahoy_email/processor.rb +14 -1
- data/lib/ahoy_email/utils.rb +2 -2
- data/lib/ahoy_email/version.rb +1 -1
- data/lib/ahoy_email.rb +4 -1
- data/lib/generators/ahoy/messages/activerecord_generator.rb +13 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e11cd64d52d35113df4fe7e29042683f3f5de6aa256ef75ae8f8455d2d1eec1f
|
4
|
+
data.tar.gz: f38baf49086ddaa1759243644074da6486cddbb0793c1d71e93e352228f12b66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd32bc570175e43d4b601d1b6bf7289f44c51912fe3b5f3fafc86cfbd505a4aa40b8c7ea224cfa0c29d790d0d9994acc92d0d143d4a482152539fec1904cce9b
|
7
|
+
data.tar.gz: 81e1d2e90a4a82621b5fb3b755653f6536cc755f3702c9d89a57e0be90b6ea1111b6cf5b737093f37e859c1c5742f137492b1ee41841125b6504623c6bd830da
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 2.4.0 (2024-11-11)
|
2
|
+
|
3
|
+
- Added `html5` option
|
4
|
+
- Improved generator for Active Record encryption and MySQL
|
5
|
+
- Removed support for Ruby < 3.1 and Rails < 7
|
6
|
+
- Removed support for Mongoid < 8
|
7
|
+
|
1
8
|
## 2.3.1 (2024-09-09)
|
2
9
|
|
3
10
|
- Fixed deprecation warning with Rails 7.1
|
@@ -180,4 +187,14 @@ Breaking changes
|
|
180
187
|
|
181
188
|
## 0.1.0 (2014-04-29)
|
182
189
|
|
183
|
-
-
|
190
|
+
- Changed option names
|
191
|
+
|
192
|
+
## 0.0.2 (2014-04-29)
|
193
|
+
|
194
|
+
- Added open and click tracking
|
195
|
+
- Added UTM parameters
|
196
|
+
- Rescue errors
|
197
|
+
|
198
|
+
## 0.0.1 (2014-04-28)
|
199
|
+
|
200
|
+
- First release
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ rails generate ahoy:messages --encryption=lockbox
|
|
33
33
|
rails db:migrate
|
34
34
|
```
|
35
35
|
|
36
|
-
To use Active Record encryption
|
36
|
+
To use Active Record encryption, run:
|
37
37
|
|
38
38
|
```sh
|
39
39
|
rails generate ahoy:messages --encryption=activerecord
|
@@ -106,7 +106,7 @@ user.messages
|
|
106
106
|
Add extra data to messages. Create a migration like:
|
107
107
|
|
108
108
|
```ruby
|
109
|
-
class AddCouponIdToAhoyMessages < ActiveRecord::Migration[
|
109
|
+
class AddCouponIdToAhoyMessages < ActiveRecord::Migration[8.0]
|
110
110
|
def change
|
111
111
|
add_column :ahoy_messages, :coupon_id, :integer
|
112
112
|
end
|
@@ -324,6 +324,16 @@ Get stats for a campaign
|
|
324
324
|
AhoyEmail.stats("my-campaign")
|
325
325
|
```
|
326
326
|
|
327
|
+
## HTML Parsing
|
328
|
+
|
329
|
+
By default, Nokogiri’s default HTML parser is used to rewrite links for UTM tagging and click analytics. This currently uses HTML4, which [only allows inline elements inside links](https://github.com/sparklemotion/nokogiri/issues/1876#issuecomment-468276937).
|
330
|
+
|
331
|
+
To use HTML5 parsing, create `config/initializers/ahoy_email.rb` with:
|
332
|
+
|
333
|
+
```ruby
|
334
|
+
AhoyEmail.default_options[:html5] = true
|
335
|
+
```
|
336
|
+
|
327
337
|
## History
|
328
338
|
|
329
339
|
View the [changelog](https://github.com/ankane/ahoy_email/blob/master/CHANGELOG.md)
|
@@ -25,7 +25,7 @@ module Ahoy
|
|
25
25
|
end
|
26
26
|
|
27
27
|
redirect_options = {}
|
28
|
-
redirect_options[:allow_other_host] = true
|
28
|
+
redirect_options[:allow_other_host] = true
|
29
29
|
|
30
30
|
if AhoyEmail::Utils.signature_verified?(legacy: legacy, token: token, campaign: campaign, url: url, signature: signature)
|
31
31
|
data = {}
|
data/lib/ahoy_email/mailer.rb
CHANGED
@@ -63,6 +63,9 @@ module AhoyEmail
|
|
63
63
|
# only call other options if needed
|
64
64
|
if options[key]
|
65
65
|
AhoyEmail::Utils::OPTION_KEYS[key].each do |k|
|
66
|
+
# make sure html5 only called once
|
67
|
+
next if options.key?(k)
|
68
|
+
|
66
69
|
v = ahoy_options[k]
|
67
70
|
options[k] = v.respond_to?(:call) ? instance_exec(&v) : v
|
68
71
|
end
|
data/lib/ahoy_email/processor.rb
CHANGED
@@ -53,7 +53,7 @@ module AhoyEmail
|
|
53
53
|
if html_part?
|
54
54
|
part = message.html_part || message
|
55
55
|
|
56
|
-
doc =
|
56
|
+
doc = parser_class.parse(part.body.raw_source)
|
57
57
|
doc.css("a[href]").each do |link|
|
58
58
|
uri = parse_uri(link["href"])
|
59
59
|
next unless trackable?(uri)
|
@@ -92,6 +92,19 @@ module AhoyEmail
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
# use document instead of fragment
|
96
|
+
# https://github.com/ankane/ahoy_email/pull/150
|
97
|
+
def parser_class
|
98
|
+
case options[:html5]
|
99
|
+
when true
|
100
|
+
Nokogiri::HTML5::Document
|
101
|
+
when false
|
102
|
+
Nokogiri::HTML4::Document
|
103
|
+
else
|
104
|
+
Nokogiri::HTML::Document
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
95
108
|
def html_part?
|
96
109
|
(message.html_part || message).content_type =~ /html/
|
97
110
|
end
|
data/lib/ahoy_email/utils.rb
CHANGED
@@ -2,8 +2,8 @@ module AhoyEmail
|
|
2
2
|
class Utils
|
3
3
|
OPTION_KEYS = {
|
4
4
|
message: %i(message mailer user extra),
|
5
|
-
utm_params: %i(utm_source utm_medium utm_term utm_content utm_campaign),
|
6
|
-
click: %i(campaign url_options unsubscribe_links)
|
5
|
+
utm_params: %i(utm_source utm_medium utm_term utm_content utm_campaign html5),
|
6
|
+
click: %i(campaign url_options unsubscribe_links html5)
|
7
7
|
}
|
8
8
|
|
9
9
|
class << self
|
data/lib/ahoy_email/version.rb
CHANGED
data/lib/ahoy_email.rb
CHANGED
@@ -34,8 +34,11 @@ module Ahoy
|
|
34
34
|
when "lockbox"
|
35
35
|
"t.text :to_ciphertext\n t.string :to_bidx, index: true"
|
36
36
|
else
|
37
|
-
|
38
|
-
|
37
|
+
if encryption == "activerecord" && mysql?
|
38
|
+
"t.string :to, limit: 510, index: true"
|
39
|
+
else
|
40
|
+
"t.string :to, index: true"
|
41
|
+
end
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
@@ -63,6 +66,14 @@ module Ahoy
|
|
63
66
|
"has_encrypted"
|
64
67
|
end
|
65
68
|
end
|
69
|
+
|
70
|
+
def mysql?
|
71
|
+
adapter =~ /mysql|trilogy/i
|
72
|
+
end
|
73
|
+
|
74
|
+
def adapter
|
75
|
+
ActiveRecord::Base.connection_db_config.adapter.to_s
|
76
|
+
end
|
66
77
|
end
|
67
78
|
end
|
68
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.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: 2024-
|
11
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7'
|
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: '
|
26
|
+
version: '7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: addressable
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: '3'
|
119
|
+
version: '3.1'
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.5.
|
126
|
+
rubygems_version: 3.5.22
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: First-party email analytics for Rails
|