forked from ankane/ahoy_email
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7032e88
Showing
15 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp | ||
*.bundle | ||
*.so | ||
*.o | ||
*.a | ||
mkmf.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in ahoy_email.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014 Andrew Kane | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Ahoy Email | ||
|
||
:construction: Coming soon - May 1, 2014 | ||
|
||
:envelope: Simple, powerful email tracking for Rails | ||
|
||
Keep track of emails: | ||
|
||
- sent | ||
- opened | ||
- clicked | ||
|
||
## Installation | ||
|
||
Add this line to your application’s Gemfile: | ||
|
||
```ruby | ||
gem 'ahoy_email' | ||
``` | ||
|
||
And run the generator. This creates a model to store messages. | ||
|
||
```sh | ||
rails generate ahoy_email:install | ||
rake db:migrate | ||
``` | ||
|
||
## How It Works | ||
|
||
Ahoy creates an `Ahoy::Message` record when an email is sent. It also adds: | ||
|
||
- open tracking | ||
- click tracking | ||
- UTM parameters | ||
|
||
## TODO | ||
|
||
- Subscription management (lists, opt-outs) | ||
|
||
## Contributing | ||
|
||
Everyone is encouraged to help improve this project. Here are a few ways you can help: | ||
|
||
- [Report bugs](https://github.com/ankane/ahoy_email/issues) | ||
- Fix bugs and [submit pull requests](https://github.com/ankane/ahoy_email/pulls) | ||
- Write, clarify, or fix documentation | ||
- Suggest or add new features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "bundler/gem_tasks" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'ahoy_email/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "ahoy_email" | ||
spec.version = AhoyEmail::VERSION | ||
spec.authors = ["Andrew Kane"] | ||
spec.email = ["andrew@chartkick.com"] | ||
spec.summary = %q{Simple, powerful email tracking for Rails} | ||
spec.description = %q{Simple, powerful email tracking for Rails} | ||
spec.homepage = "https://github.com/ankane/ahoy_email" | ||
spec.license = "MIT" | ||
|
||
spec.files = `git ls-files -z`.split("\x0") | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_dependency "actionmailer" | ||
|
||
spec.add_development_dependency "bundler", "~> 1.6" | ||
spec.add_development_dependency "rake" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Ahoy | ||
class MessagesController < ActionController::Base | ||
|
||
def open | ||
puts "OPENED!" | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Ahoy | ||
class Message < ActiveRecord::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Rails.application.routes.draw do | ||
mount AhoyEmail::Engine => "/ahoy" | ||
end | ||
|
||
AhoyEmail::Engine.routes.draw do | ||
resources :messages, only: [] do | ||
get :open, on: :collection | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require "ahoy_email/version" | ||
require "action_mailer" | ||
require "ahoy_email/interceptor" | ||
require "ahoy_email/engine" | ||
|
||
ActionMailer::Base.register_interceptor AhoyEmail::Interceptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module AhoyEmail | ||
class Engine < ::Rails::Engine | ||
isolate_namespace AhoyEmail | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module AhoyEmail | ||
class Interceptor | ||
# include ActionView::Helpers::AssetTagHelper | ||
|
||
def self.delivering_email(message) | ||
# body = (message.html_part || message).body.raw_source | ||
# p AhoyEmail::Engine.routes | ||
# if body | ||
# regex = /<\/body>/i | ||
# pixel = image_tag(AhoyEmail::Engine.routes.url_helpers.url_for(controller: "messages", action: "open")) | ||
# if body.match(regex) | ||
# body.gsub!(regex, "#{pixel}\\0") | ||
# else | ||
# body << pixel | ||
# end | ||
# end | ||
Ahoy::Message.create!( | ||
subject: message.subject, | ||
content: message.to_s | ||
) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module AhoyEmail | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb | ||
require "rails/generators" | ||
require "rails/generators/migration" | ||
require "active_record" | ||
require "rails/generators/active_record" | ||
|
||
module AhoyEmail | ||
module Generators | ||
class InstallGenerator < Rails::Generators::Base | ||
include Rails::Generators::Migration | ||
|
||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
# Implement the required interface for Rails::Generators::Migration. | ||
def self.next_migration_number(dirname) #:nodoc: | ||
next_migration_number = current_migration_number(dirname) + 1 | ||
if ActiveRecord::Base.timestamped_migrations | ||
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max | ||
else | ||
"%.3d" % next_migration_number | ||
end | ||
end | ||
|
||
def copy_migration | ||
migration_template "install.rb", "db/migrate/create_ahoy_messages.rb" | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class <%= migration_class_name %> < ActiveRecord::Migration | ||
def change | ||
create_table :ahoy_messages do |t| | ||
# user | ||
t.integer :user_id | ||
t.string :user_type | ||
|
||
# message | ||
t.text :subject | ||
t.text :content | ||
|
||
# timestamps | ||
t.timestamp :sent_at | ||
t.timestamp :opened_at | ||
t.timestamp :clicked_at | ||
end | ||
|
||
add_index :ahoy_messages, [:user_id, :user_type] | ||
end | ||
end |