ahoy_email 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6c59b97a0029bef3d6070fc62b01b4c6f79b476
4
- data.tar.gz: 6cbc7dec76e337280204d5cb420e71a0b20b6a19
3
+ metadata.gz: 784f96fb14f9b6b23c849aa435ffbbf3acdac543
4
+ data.tar.gz: 6cc58343026c75ad6536665617838a5b593669ad
5
5
  SHA512:
6
- metadata.gz: 346a685b5fc9f4a3e743b845eb1d74faf69993e7a04c01ab01a971d4d7045f621c0699f311603f8b0f7d9704ca834cd6d20ecb249d71b55c93079886a96d7e9e
7
- data.tar.gz: 4261c2b50159e022b7ec6875b27cfc37006702385771329446664be6cf17c5ba4ae1c9c7e2869b33b5127b76c81957a069c411b9207fd21072efd2a2123ce0ca
6
+ metadata.gz: a19c3241eeaa13893da620b0eea2d35dda95948a5603591e33067de0805e0daad208929da1d6d6f86b26b1a6c93598e2c51536888d1a0215b93c9d6957651c84
7
+ data.tar.gz: cc06e0550beaff17574a3f57108cd444584c5d17eb7a91bc7efa8b81f7f2f42fe3cc8937c97110f8b1c09fa4a010cf60977d86c210d83730d7fbcc603c806d2f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.4
2
+
3
+ - Added `extra` option for extra attributes
4
+
1
5
  ## 0.2.3
2
6
 
3
7
  - Save utm parameters
data/README.md CHANGED
@@ -114,6 +114,14 @@ Use `track utm_params: false` to skip tagging, or skip specific links with:
114
114
  <a data-skip-utm-params="true" href="...">Break it down</a>
115
115
  ```
116
116
 
117
+ ### Extra Attributes
118
+
119
+ Create a migration to add extra attributes to the `ahoy_messages` table and use:
120
+
121
+ ```ruby
122
+ track extra: {campaign_id: 1}
123
+ ```
124
+
117
125
  ## Customize
118
126
 
119
127
  ### Tracking
@@ -218,6 +226,12 @@ Use a different model
218
226
  AhoyEmail.message_model = UserMessage
219
227
  ```
220
228
 
229
+ ## Upgrading
230
+
231
+ ### 0.2.3
232
+
233
+ Optionally, you can store UTM parameters by adding `utm_source`, `utm_medium`, and `utm_campaign` columns to your message model.
234
+
221
235
  ## History
222
236
 
223
237
  View the [changelog](https://github.com/ankane/ahoy_email/blob/master/CHANGELOG.md)
@@ -2,6 +2,8 @@ module AhoyEmail
2
2
  class Processor
3
3
  attr_reader :message, :mailer, :ahoy_message
4
4
 
5
+ UTM_PARAMETERS = %w(utm_source utm_medium utm_term utm_content utm_campaign)
6
+
5
7
  def initialize(message, mailer = nil)
6
8
  @message = message
7
9
  @mailer = mailer
@@ -18,13 +20,16 @@ module AhoyEmail
18
20
  track_open if options[:open]
19
21
  track_links if options[:utm_params] || options[:click]
20
22
 
21
- ahoy_message.utm_source = options[:utm_source] if ahoy_message.respond_to?(:utm_source=)
22
- ahoy_message.utm_medium = options[:utm_medium] if ahoy_message.respond_to?(:utm_medium=)
23
- ahoy_message.utm_campaign = options[:utm_campaign] if ahoy_message.respond_to?(:utm_campaign=)
24
23
  ahoy_message.mailer = options[:mailer] if ahoy_message.respond_to?(:mailer=)
25
24
  ahoy_message.subject = message.subject if ahoy_message.respond_to?(:subject=)
26
25
  ahoy_message.content = message.to_s if ahoy_message.respond_to?(:content=)
27
26
 
27
+ UTM_PARAMETERS.each do |k|
28
+ ahoy_message.send("#{k}=", options[k.to_sym]) if ahoy_message.respond_to?("#{k}=")
29
+ end
30
+
31
+ ahoy_message.assign_attributes(options[:extra] || {})
32
+
28
33
  ahoy_message.save
29
34
  message["Ahoy-Message-Id"] = ahoy_message.id.to_s
30
35
  end
@@ -98,7 +103,7 @@ module AhoyEmail
98
103
  if options[:utm_params] && !skip_attribute?(link, "utm-params")
99
104
  uri = Addressable::URI.parse(link["href"])
100
105
  params = uri.query_values || {}
101
- %w(utm_source utm_medium utm_term utm_content utm_campaign).each do |key|
106
+ UTM_PARAMETERS.each do |key|
102
107
  params[key] ||= options[key.to_sym] if options[key.to_sym]
103
108
  end
104
109
  uri.query_values = params
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -8,14 +8,17 @@ class <%= migration_class_name %> < ActiveRecord::Migration
8
8
  t.integer :user_id
9
9
  t.string :user_type
10
10
 
11
- # optional
12
- # feel free to remove
11
+ # optional - feel free to remove
13
12
  t.string :mailer
14
13
  t.text :subject
15
14
  t.text :content
16
- t.string :utm_source
17
- t.string :utm_medium
18
- t.string :utm_campaign
15
+
16
+ # optional
17
+ # t.string :utm_source
18
+ # t.string :utm_medium
19
+ # t.string :utm_term
20
+ # t.string :utm_content
21
+ # t.string :utm_campaign
19
22
 
20
23
  # timestamps
21
24
  t.timestamp :sent_at
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: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails