ahoy_email 2.3.0 → 2.4.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 +4 -4
- data/CHANGELOG.md +22 -1
- data/README.md +9 -47
- data/app/controllers/ahoy/messages_controller.rb +1 -1
- data/lib/ahoy_email/engine.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,14 @@
|
|
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
|
+
|
8
|
+
## 2.3.1 (2024-09-09)
|
9
|
+
|
10
|
+
- Fixed deprecation warning with Rails 7.1
|
11
|
+
|
1
12
|
## 2.3.0 (2024-06-01)
|
2
13
|
|
3
14
|
- Added support for secret token rotation
|
@@ -176,4 +187,14 @@ Breaking changes
|
|
176
187
|
|
177
188
|
## 0.1.0 (2014-04-29)
|
178
189
|
|
179
|
-
-
|
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
|
@@ -156,7 +156,7 @@ end
|
|
156
156
|
Delete older data with:
|
157
157
|
|
158
158
|
```ruby
|
159
|
-
Ahoy::Message.where("
|
159
|
+
Ahoy::Message.where("sent_at < ?", 1.year.ago).in_batches.delete_all
|
160
160
|
```
|
161
161
|
|
162
162
|
Delete data for a specific user with:
|
@@ -324,53 +324,15 @@ Get stats for a campaign
|
|
324
324
|
AhoyEmail.stats("my-campaign")
|
325
325
|
```
|
326
326
|
|
327
|
-
##
|
327
|
+
## HTML Parsing
|
328
328
|
|
329
|
-
|
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
330
|
|
331
|
-
|
331
|
+
To use HTML5 parsing, create `config/initializers/ahoy_email.rb` with:
|
332
332
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
```ruby
|
338
|
-
class Ahoy::Message < ActiveRecord::Base
|
339
|
-
self.table_name = "ahoy_messages"
|
340
|
-
|
341
|
-
belongs_to :user, polymorphic: true, optional: true
|
342
|
-
|
343
|
-
encrypts :to, migrating: true
|
344
|
-
blind_index :to, migrating: true
|
345
|
-
end
|
346
|
-
```
|
347
|
-
|
348
|
-
- The `track` method has been broken into:
|
349
|
-
|
350
|
-
- `has_history` for message history
|
351
|
-
- `utm_params` for UTM tagging
|
352
|
-
- `track_clicks` for click analytics
|
353
|
-
|
354
|
-
- Message history is no longer enabled by default. Add `has_history` to individual mailers, or create an initializer with:
|
355
|
-
|
356
|
-
```ruby
|
357
|
-
AhoyEmail.default_options[:message] = true
|
358
|
-
```
|
359
|
-
|
360
|
-
- For privacy, open tracking has been removed.
|
361
|
-
|
362
|
-
- For clicks, we encourage you to try [aggregate analytics](#click-analytics) to measure the performance of campaigns. You can use a library like [Rollup](https://github.com/ankane/rollup) to aggregate existing data, then drop the `token` and `clicked_at` columns.
|
363
|
-
|
364
|
-
To keep individual analytics, use `has_history` and `track_clicks campaign: false` and create an initializer with:
|
365
|
-
|
366
|
-
```ruby
|
367
|
-
AhoyEmail.save_token = true
|
368
|
-
AhoyEmail.subscribers << AhoyEmail::MessageSubscriber
|
369
|
-
```
|
370
|
-
|
371
|
-
If you use a custom subscriber, `:message` is no longer included in click events. You can use `:token` to query the message if needed.
|
372
|
-
|
373
|
-
- Users are shown a link expired page when signature verification fails instead of being redirected to the homepage when `AhoyEmail.invalid_redirect_url` is not set
|
333
|
+
```ruby
|
334
|
+
AhoyEmail.default_options[:html5] = true
|
335
|
+
```
|
374
336
|
|
375
337
|
## History
|
376
338
|
|
@@ -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/engine.rb
CHANGED
@@ -11,7 +11,7 @@ module AhoyEmail
|
|
11
11
|
creds =
|
12
12
|
if app.respond_to?(:credentials) && app.credentials.secret_key_base
|
13
13
|
app.credentials
|
14
|
-
elsif app.respond_to?(:secrets)
|
14
|
+
elsif app.respond_to?(:secrets) && (Rails::VERSION::STRING.to_f < 7.1 || app.config.paths["config/secrets"].existent.any?)
|
15
15
|
app.secrets
|
16
16
|
else
|
17
17
|
app.config
|
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
|