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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 042ad39e2a371bd33d437f9187d691b665ae267c664703656baa3f7c40612fac
4
- data.tar.gz: bf6e213b94b8002cd53767272cbdd1a2ea16ac24008c47439e9376615cde04db
3
+ metadata.gz: e39b9c6d5b1c32cc0a7a1bcc5da1e08205d6187e8eb5aec1505295ac1de36c64
4
+ data.tar.gz: c8f94cc014a6ab2cebe9c718a02989505fa9086d4b6bdbaed1e35a13bf269259
5
5
  SHA512:
6
- metadata.gz: f7d589c0b45ac51efaaf7045d4578810c47524ec43a6ea8a82e65c1d975e86aba45abd8e73d0f6c6a0b7d999cd1e352ffae8113df347de81ecda3108982fd4c2
7
- data.tar.gz: '0598b1f93fde1645f490e8ab4f02032520f707045b651dfb857b02bad78573b26d1b84f9e317a86c2c9e1126e078d43b1f2e0bc93db3e5fee14db60c6afd08e0'
6
+ metadata.gz: fc2721f83dc1eb2098d4d16166c3e78a07184007b61fd320ab4e50b26dc8dcc34583482baf8af1154d1b12e904c9113a69f4f3d24b18c1efc5dc26cf88e19aa2
7
+ data.tar.gz: 20f100d9f5c34ed8553ef778e4330df5cf35458d50f1bcfb2a28cdf3e6b8750d59b65b1dc153b23c773db4959ae10e051a28828852b0da06064c18a10f8c685c
@@ -1,3 +1,8 @@
1
+ ## 1.0.2
2
+
3
+ - Fixed error with Ruby < 2.5
4
+ - Fixed UTM parameters storage on model
5
+
1
6
  ## 1.0.1
2
7
 
3
8
  - Use observer instead of interceptor
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 UserMailer < ApplicationMailer
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 UserMailer < ApplicationMailer
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 UserMailer < ApplicationMailer
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
@@ -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.user_type = data[:user_type]
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
@@ -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.to_sym] if options[k.to_sym]
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
 
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  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: 1.0.1
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-09-27 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer