ahoy_email 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +20 -3
- data/lib/ahoy_email.rb +2 -3
- data/lib/ahoy_email/processor.rb +5 -3
- data/lib/ahoy_email/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e39b9c6d5b1c32cc0a7a1bcc5da1e08205d6187e8eb5aec1505295ac1de36c64
|
4
|
+
data.tar.gz: c8f94cc014a6ab2cebe9c718a02989505fa9086d4b6bdbaed1e35a13bf269259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc2721f83dc1eb2098d4d16166c3e78a07184007b61fd320ab4e50b26dc8dcc34583482baf8af1154d1b12e904c9113a69f4f3d24b18c1efc5dc26cf88e19aa2
|
7
|
+
data.tar.gz: 20f100d9f5c34ed8553ef778e4330df5cf35458d50f1bcfb2a28cdf3e6b8750d59b65b1dc153b23c773db4959ae10e051a28828852b0da06064c18a10f8c685c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -38,7 +38,7 @@ rails db:migrate
|
|
38
38
|
Ahoy creates an `Ahoy::Message` record for each email sent by default. You can disable history for a mailer:
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
class
|
41
|
+
class CouponMailer < ApplicationMailer
|
42
42
|
track message: false # use only/except to limit actions
|
43
43
|
end
|
44
44
|
```
|
@@ -58,7 +58,7 @@ By default, Ahoy tries `@user` then `params[:user]` then `User.find_by(email: me
|
|
58
58
|
You can pass a specific user with:
|
59
59
|
|
60
60
|
```ruby
|
61
|
-
class
|
61
|
+
class CouponMailer < ApplicationMailer
|
62
62
|
track user: -> { params[:some_user] }
|
63
63
|
end
|
64
64
|
```
|
@@ -168,7 +168,7 @@ AhoyEmail.api = true
|
|
168
168
|
And add to mailers you want to track:
|
169
169
|
|
170
170
|
```ruby
|
171
|
-
class
|
171
|
+
class CouponMailer < ApplicationMailer
|
172
172
|
track open: true, click: true # use only/except to limit actions
|
173
173
|
end
|
174
174
|
```
|
@@ -265,6 +265,23 @@ AhoyEmail.track_method = lambda do |data|
|
|
265
265
|
end
|
266
266
|
```
|
267
267
|
|
268
|
+
## Mongoid
|
269
|
+
|
270
|
+
If you prefer to use Mongoid instead of ActiveRecord, create `app/models/ahoy/message.rb` with:
|
271
|
+
|
272
|
+
```ruby
|
273
|
+
class Ahoy::Message
|
274
|
+
include Mongoid::Document
|
275
|
+
|
276
|
+
belongs_to :user, polymorphic: true, optional: true, index: true
|
277
|
+
|
278
|
+
field :to, type: String
|
279
|
+
field :mailer, type: String
|
280
|
+
field :subject, type: String
|
281
|
+
field :sent_at, type: Time
|
282
|
+
end
|
283
|
+
```
|
284
|
+
|
268
285
|
## Upgrading
|
269
286
|
|
270
287
|
### 1.0
|
data/lib/ahoy_email.rb
CHANGED
@@ -41,8 +41,7 @@ module AhoyEmail
|
|
41
41
|
|
42
42
|
ahoy_message = AhoyEmail.message_model.new
|
43
43
|
ahoy_message.to = Array(message.to).join(", ") if ahoy_message.respond_to?(:to=)
|
44
|
-
ahoy_message.
|
45
|
-
ahoy_message.user_id = data[:user_id]
|
44
|
+
ahoy_message.user = data[:user]
|
46
45
|
|
47
46
|
ahoy_message.mailer = data[:mailer] if ahoy_message.respond_to?(:mailer=)
|
48
47
|
ahoy_message.subject = message.subject if ahoy_message.respond_to?(:subject=)
|
@@ -76,5 +75,5 @@ end
|
|
76
75
|
ActiveSupport.on_load(:action_mailer) do
|
77
76
|
include AhoyEmail::Mailer
|
78
77
|
register_observer AhoyEmail::Observer
|
79
|
-
Mail::Message.attr_accessor :ahoy_data, :ahoy_message
|
78
|
+
Mail::Message.send(:attr_accessor, :ahoy_data, :ahoy_message)
|
80
79
|
end
|
data/lib/ahoy_email/processor.rb
CHANGED
@@ -31,9 +31,11 @@ module AhoyEmail
|
|
31
31
|
def track_message
|
32
32
|
data = {
|
33
33
|
mailer: options[:mailer],
|
34
|
-
extra: options[:extra]
|
34
|
+
extra: options[:extra],
|
35
|
+
user: options[:user]
|
35
36
|
}
|
36
37
|
|
38
|
+
# legacy, remove in next major version
|
37
39
|
user = options[:user]
|
38
40
|
if user
|
39
41
|
data[:user_type] = user.model_name.name
|
@@ -46,8 +48,8 @@ module AhoyEmail
|
|
46
48
|
end
|
47
49
|
|
48
50
|
if options[:utm_params]
|
49
|
-
UTM_PARAMETERS.each do |k|
|
50
|
-
data[k] = options[k
|
51
|
+
UTM_PARAMETERS.map(&:to_sym).each do |k|
|
52
|
+
data[k] = options[k] if options[k]
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
data/lib/ahoy_email/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|