mail_spy 0.0.2 → 0.1.1

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.
Files changed (56) hide show
  1. data/README.rdoc +86 -24
  2. data/app/assets/images/mail_spy/background_tile.gif +0 -0
  3. data/app/assets/images/mail_spy/mailspy_sprite.png +0 -0
  4. data/app/assets/images/mail_spy/spy.ico +0 -0
  5. data/app/assets/javascripts/mail_spy/lib/backbone.js +1256 -0
  6. data/app/assets/javascripts/mail_spy/lib/underscore.js +999 -0
  7. data/app/assets/javascripts/mail_spy/reports.js +2 -0
  8. data/app/assets/javascripts/mail_spy/sendgrid.js +2 -0
  9. data/app/assets/stylesheets/mail_spy/application.css +62 -1
  10. data/app/assets/stylesheets/mail_spy/reports.css.scss +128 -0
  11. data/app/assets/stylesheets/mail_spy/sendgrid.css +4 -0
  12. data/app/controllers/mail_spy/reports_controller.rb +29 -0
  13. data/app/controllers/mail_spy/sendgrid_controller.rb +26 -0
  14. data/app/controllers/mail_spy/tracking_controller.rb +19 -11
  15. data/app/helpers/mail_spy/email_helper.rb +21 -3
  16. data/app/helpers/mail_spy/reports_helper.rb +4 -0
  17. data/app/helpers/mail_spy/sendgrid_helper.rb +4 -0
  18. data/app/mailers/mail_spy/core_mailer.rb +15 -18
  19. data/app/models/mail_spy/email.rb +127 -19
  20. data/app/models/mail_spy/process_log.rb +25 -0
  21. data/app/views/layouts/mail_spy/application.html.erb +3 -0
  22. data/app/views/mail_spy/reports/campaigns.html.erb +138 -0
  23. data/config/routes.rb +6 -0
  24. data/lib/generators/mail_spy/templates/mail_spy.rb +25 -1
  25. data/lib/mail_spy/manager.rb +100 -54
  26. data/lib/mail_spy/sendgrid/smtp_api_header.rb +68 -0
  27. data/lib/mail_spy/version.rb +1 -1
  28. data/lib/mail_spy.rb +39 -5
  29. data/test/dummy/app/views/email_templates/helper_test.html.erb +15 -0
  30. data/test/dummy/app/views/email_templates/helper_test.text.erb +11 -0
  31. data/test/dummy/config/environments/development.rb +1 -1
  32. data/test/dummy/config/environments/production.rb +5 -1
  33. data/test/dummy/config/environments/test.rb +4 -1
  34. data/test/dummy/config/initializers/mail_spy.rb +42 -0
  35. data/test/dummy/config/routes.rb +1 -2
  36. data/test/dummy/db/schema.rb +16 -0
  37. data/test/dummy/db/seeds.rb +16 -13
  38. data/test/dummy/lib/tasks/emails.rake +8 -0
  39. data/test/dummy/log/development.log +782 -0
  40. data/test/dummy/log/test.log +9952 -0
  41. data/test/fixtures/mail_spy/process_logs.yml +15 -0
  42. data/test/functional/mail_spy/core_mailer_test.rb +16 -9
  43. data/test/functional/mail_spy/reports_controller_test.rb +9 -0
  44. data/test/functional/mail_spy/sendgrid_controller_test.rb +9 -0
  45. data/test/functional/mail_spy/tracking_controller_test.rb +16 -11
  46. data/test/test_email_credentials.yml +2 -2
  47. data/test/test_email_credentials.yml.sample +0 -8
  48. data/test/test_helper.rb +15 -41
  49. data/test/unit/helpers/mail_spy/reports_helper_test.rb +6 -0
  50. data/test/unit/helpers/mail_spy/sendgrid_helper_test.rb +6 -0
  51. data/test/unit/mail_spy/manager_test.rb +101 -122
  52. data/test/unit/mail_spy/{email_template_test.rb → process_log_test.rb} +1 -1
  53. metadata +122 -34
  54. data/app/models/mail_spy/email_template.rb +0 -17
  55. data/test/fixtures/mail_spy/email_templates.yml +0 -9
  56. /data/lib/generators/mail_spy/{initialize_generator.rb → initializer_generator.rb} +0 -0
data/README.rdoc CHANGED
@@ -12,57 +12,119 @@ Add gem "mailspy" to your Gemfile
12
12
  gem "mailspy"
13
13
 
14
14
 
15
+ If you haven't already create a mongoid.yml file for the mongodb connection
16
+ rails generate mongoid:config
17
+
18
+ If you are going to be sending on one machine make sure to scale up the pool
19
+ from the default of 1 to 10+ to get good performance. Timeouts are also a good idea
20
+
15
21
  Create the mongoid configuration for the mongo db
16
22
 
17
- rails g mailspy:initialize
23
+ rails g mail_spy:initializer
18
24
 
19
- Fill out the generated mailspy_mongoid.yml with the mongodb configuration settings
25
+ Fill out the generated mailspy.rb with your esp settings (file has example)
26
+ and AWS settings
20
27
 
21
28
  Then mount the engine in the routes.rb file
22
29
  Rails.application.routes.draw do
23
- mount MailSpy::Engine => "/mailspy"
30
+ mount MailSpy::Engine => "/mail"
24
31
  end
25
32
 
33
+ Finally run rake db:mongoid:create_indexes to get performant sends
34
+
26
35
  == Usage
27
36
 
28
- To start using the viral tool simply enable it by
37
+ Mailspy is centered around email templates and instances of those templates
38
+ (aka emails).
29
39
 
30
- Adding the Virality module to Application Controller
31
- class ApplicationController < ActionController::Base
32
- include Virality
33
- before_filter :track_virality
40
+ To create a template:
41
+ add a template to your s3 directory, campaign/stream/component.(text|html).erb
34
42
 
35
- end
36
43
 
37
- This will give you access to the following methods in lib/virality.rb these
38
- methods are the complete client interface for the tool.
44
+ To create a instance:
45
+
46
+ MailSpy.create_email(options)
47
+
48
+ required options include:
49
+
50
+ * :campaign :top level grouping
51
+ * :stream : mid level grouping
52
+ * :component : bottom level grouping
53
+ * :schedule_at
54
+ * :subject
55
+ * :template_values
56
+ * :from
57
+ * :reply_to
58
+ * one of [:to, :cc, :bcc]
59
+
60
+
61
+ == Sendgrid
62
+
63
+ MailSpy has bindings baked in for sendgrid event notification.
64
+
65
+ To enable simply configure sendgrid to send post notifications (no batch support yet)
66
+ to YOUR_HOST/mount_path/sendgrid/notification
67
+
68
+ The mount path is usually 'mail' but is configurable in your routes file
39
69
 
40
- You will want to get started by instrumenting you code with the record_* methods
41
- and using the message_for_conceit to populate your channel messages
70
+ finally add
42
71
 
72
+ esp.options = {
73
+ :enable_sendgrid_event_tracking => true
74
+ }
43
75
 
76
+ to your initializers/mail_spy.rb file
44
77
 
45
- == packaging into a application
78
+ This will automatically add in the sendgrid smtp api headers and record all
79
+ events you have setup using the sendgrid admin interface.
46
80
 
47
- If you don't have a private gem server you can package the gem into your
48
- application since its not open source...
81
+ Reminder: If you are using open and click tracking using MailSpy adding them
82
+ to sendgrid will be redundant and harmful.
49
83
 
50
- 1) gem build viral.gemspec
51
- 2) rvm 1.9.2@global gem install viral-0.7.3.gem
52
- 3) gem unpack viral -v '0.7.3' --target vendor/gems/
53
- 4) Add the gemspec file to the vendored unpacked gem.
54
- 5) bundle install
84
+ == Google Analytics
85
+
86
+ MailSpy has automatic bindings for google analytics.
87
+
88
+ MailSpy requires that all emails form into the campaign, stream, component
89
+ structure which lends itself nicely to a direct mapping in google analytics.
90
+
91
+ utm_source => MailSpy - #{tracker_host}
92
+ utm_medium => email
93
+ utm_campaign => campaign
94
+ utm_term => stream
95
+ utm_content => component
96
+
97
+ To enable automatic bindings with all links generated by 'track_link' and
98
+ helper simply add
99
+
100
+ esp.options = {
101
+ :enable_auto_google_analytics => true
102
+ }
103
+
104
+ to your initializers/mail_spy.rb file
105
+
106
+ if you prefer to assign GA settings manually you can do that directly as
107
+ a option to MailSpy.create_email
108
+
109
+ the keys are:
110
+
111
+ * utm_source
112
+ * utm_medium
113
+ * utm_campaign
114
+ * utm_term
115
+ * utm_content
116
+
117
+ Again only links built with track_link will benefit from the GA tokens
55
118
 
56
119
  == Testing
57
120
 
58
- You will need to add your own database.yml to the dummy app, rake db:create, and
121
+ You will need to add your own mongoid.yml to the dummy app, rake db:create, and
59
122
  rake db:migrate and rake db:test:prepare to get the dummy app setup.
60
123
 
61
124
  Then you can simply run rake from the plugins test directory
62
125
 
126
+ TODO explain the test_email_credentials.yml file in /test
63
127
 
64
128
 
65
129
  == License
66
- This project is property of Ooga Labs and not open source software
67
-
68
130
  This project rocks and uses MIT-LICENSE.
Binary file