land 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.ruby-version +1 -0
  4. data/Appraisals +15 -0
  5. data/CHANGELOG.md +6 -0
  6. data/Gemfile +20 -0
  7. data/MIT-LICENSE +25 -0
  8. data/README.md +55 -0
  9. data/Rakefile +61 -0
  10. data/TODO.md +1 -0
  11. data/app/helpers/land/helper.rb +5 -0
  12. data/app/jobs/land/application_job.rb +4 -0
  13. data/app/lookups/land/ad_group.rb +9 -0
  14. data/app/lookups/land/ad_type.rb +9 -0
  15. data/app/lookups/land/affiliate.rb +9 -0
  16. data/app/lookups/land/app.rb +9 -0
  17. data/app/lookups/land/bid_match_type.rb +9 -0
  18. data/app/lookups/land/brand.rb +9 -0
  19. data/app/lookups/land/browser.rb +9 -0
  20. data/app/lookups/land/campaign.rb +10 -0
  21. data/app/lookups/land/content.rb +9 -0
  22. data/app/lookups/land/creative.rb +9 -0
  23. data/app/lookups/land/device.rb +9 -0
  24. data/app/lookups/land/device_type.rb +9 -0
  25. data/app/lookups/land/domain.rb +9 -0
  26. data/app/lookups/land/event_type.rb +9 -0
  27. data/app/lookups/land/experiment.rb +9 -0
  28. data/app/lookups/land/http_method.rb +9 -0
  29. data/app/lookups/land/keyword.rb +9 -0
  30. data/app/lookups/land/match_type.rb +9 -0
  31. data/app/lookups/land/medium.rb +9 -0
  32. data/app/lookups/land/mime_type.rb +9 -0
  33. data/app/lookups/land/network.rb +9 -0
  34. data/app/lookups/land/path.rb +10 -0
  35. data/app/lookups/land/placement.rb +9 -0
  36. data/app/lookups/land/platform.rb +10 -0
  37. data/app/lookups/land/position.rb +9 -0
  38. data/app/lookups/land/query_string.rb +10 -0
  39. data/app/lookups/land/search_term.rb +9 -0
  40. data/app/lookups/land/source.rb +9 -0
  41. data/app/lookups/land/subsource.rb +9 -0
  42. data/app/lookups/land/target.rb +9 -0
  43. data/app/lookups/land/user_agent_type.rb +9 -0
  44. data/app/models/concerns/land/table_name.rb +11 -0
  45. data/app/models/land/application_record.rb +5 -0
  46. data/app/models/land/attribution.rb +63 -0
  47. data/app/models/land/cookie.rb +14 -0
  48. data/app/models/land/event.rb +10 -0
  49. data/app/models/land/owner.rb +10 -0
  50. data/app/models/land/ownership.rb +8 -0
  51. data/app/models/land/pageview.rb +21 -0
  52. data/app/models/land/referer.rb +19 -0
  53. data/app/models/land/user_agent.rb +16 -0
  54. data/app/models/land/visit.rb +18 -0
  55. data/bin/console +13 -0
  56. data/bin/rails +22 -0
  57. data/bin/setup +11 -0
  58. data/config.ru +13 -0
  59. data/db/migrate/20200103012916_create_land_schema.rb +227 -0
  60. data/gemfiles/rails_5.0.gemfile +13 -0
  61. data/gemfiles/rails_5.1.gemfile +13 -0
  62. data/gemfiles/rails_5.2.gemfile +13 -0
  63. data/gemfiles/rails_6.0.gemfile +13 -0
  64. data/land.gemspec +56 -0
  65. data/lib/generators/land/install_generator.rb +17 -0
  66. data/lib/generators/templates/land.rb +29 -0
  67. data/lib/land.rb +30 -0
  68. data/lib/land/action.rb +62 -0
  69. data/lib/land/config.rb +62 -0
  70. data/lib/land/engine.rb +18 -0
  71. data/lib/land/tracker.rb +293 -0
  72. data/lib/land/trackers/noop_tracker.rb +8 -0
  73. data/lib/land/trackers/user_tracker.rb +79 -0
  74. data/lib/land/version.rb +5 -0
  75. data/lib/tasks/land_tasks.rake +4 -0
  76. metadata +233 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f1581c60af118cdf4c5e5176abfb178c30e3e37ecc5fe4f6d3a73bb839ff1725
4
+ data.tar.gz: b1db6762f06f4d51e4b1aefe49c5ce5811559a6b4b498ec3cf7c9191974ce9be
5
+ SHA512:
6
+ metadata.gz: aa4a91ca848fec1ae0c83e72c0203571fa13941c3ef2c69d3352d962a2901b7e6844a2bab8afc2c81b27d2d094819027129fe95ea16e54fc0af8ea9ae1c69130
7
+ data.tar.gz: 8598411cc72d6845dc7535ed35c8b4a08edd660650c5f33ab114a0a9389313da3950a2f3d6f7117bfca83359716f4c4a09b871d35fa9f7df306976fd8925377c
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ .bundle/
3
+ gemfiles/*.lock
4
+ pkg/
5
+ rdoc/
6
+ spec/examples.txt
@@ -0,0 +1 @@
1
+ ruby-2.6.6
@@ -0,0 +1,15 @@
1
+ appraise "rails-5.0" do
2
+ gem "activerecord", "~> 5.0.0"
3
+ end
4
+
5
+ appraise "rails-5.1" do
6
+ gem "activerecord", "~> 5.1.0"
7
+ end
8
+
9
+ appraise "rails-5.2" do
10
+ gem "activerecord", "~> 5.2.0"
11
+ end
12
+
13
+ appraise "rails-6.0" do
14
+ gem "activerecord", "~> 6.0.0"
15
+ end
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ See README.md before updating this file.
4
+
5
+ ## 0.1.0
6
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in land.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # gem "pry", github: "pry/pry"
15
+
16
+ group :development, :test do
17
+ gem "combustion"
18
+ gem "pry-rails"
19
+ gem "simplecov", require: false
20
+ end
@@ -0,0 +1,25 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Erik Peterson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ Some code originated from github.com/enova/landable
25
+ Copyright 2013 Enova International
@@ -0,0 +1,55 @@
1
+ # Land
2
+ Land is a clickstream tracker for Rails applications. It will track visits, pageviews, marketing attribution and more.
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'land'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or, install it yourself:
16
+
17
+ $ gem install land
18
+
19
+ To copy migrations to db/migrate run:
20
+
21
+ $ rails land:install:migrations
22
+
23
+ ## Configuration
24
+
25
+ Install with:
26
+
27
+ $ rails g land:install
28
+
29
+ Then edit `config/initializers/land.rb`.
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies, create database, and confirm test suite is working. You can also run `rails console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ To start a console run `bin/rails console` or `rails c`
38
+
39
+ ## Testing
40
+
41
+ Land uses a gem called __appraisal__ to test against multiple versions of Rails. Another gem, __combustion__ provides a minimal environment to run Rails.
42
+
43
+ Setup your database using `rails db:drop db:create db:migrate`.
44
+
45
+ To run the test suite against all versions of rails run `rake` or `appraisal rspec`.
46
+ To run the test suite against just the latest version of rails run `rspec`.
47
+
48
+ [Appraisal](https://github.com/thoughtbot/appraisal) | [Combustion](https://github.com/pat/combustion)
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/companygardener/land.
53
+
54
+ ## License
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,61 @@
1
+ begin
2
+ require "bundler/setup"
3
+ require "bundler/gem_tasks"
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ require 'lookup_by'
9
+ require "combustion"
10
+
11
+ Combustion::Application.configure_for_combustion
12
+ Combustion::Application.load_tasks
13
+
14
+ if defined?(ActiveRecord)
15
+ ActiveRecord::Base.schema_format = :sql
16
+ end
17
+
18
+ require "rspec/core/rake_task"
19
+ RSpec::Core::RakeTask.new(:spec)
20
+
21
+ require 'rdoc/task'
22
+
23
+ RDoc::Task.new(:rdoc) do |rdoc|
24
+ rdoc.rdoc_dir = 'rdoc'
25
+ rdoc.title = 'Land'
26
+ rdoc.options << '--line-numbers'
27
+ rdoc.rdoc_files.include('README.md')
28
+ rdoc.rdoc_files.include('lib/**/*.rb')
29
+ end
30
+
31
+ # Lifted from appraisal/task to avoid deprecated clutter.
32
+ desc "Run the given task for all appraisals"
33
+ task :appraisal do
34
+ ARGV.shift
35
+ exec "bundle exec appraisal rake #{ARGV.join(' ')}"
36
+ end
37
+
38
+ if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
39
+ task default: :appraisal
40
+ else
41
+ task default: :spec
42
+ end
43
+
44
+ # Clean up some clutter in `rake -T`.
45
+ %w[
46
+ app:template
47
+ app:update
48
+ restart
49
+ ].each { |name| Rake::Task[name].clear }
50
+
51
+ %w[
52
+ clean
53
+ clobber_rdoc
54
+ install:local
55
+ log:clear
56
+ rerdoc
57
+ secret
58
+ time:zones
59
+ tmp:clear
60
+ tmp:create
61
+ ].each { |name| Rake::Task[name].clear_comments }
data/TODO.md ADDED
@@ -0,0 +1 @@
1
+ - Add support for circle ci
@@ -0,0 +1,5 @@
1
+ module Land
2
+ module Helper
3
+ attr_reader :land
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Land
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class AdGroup < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :ad_group, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class AdType < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :ad_type, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Affiliate < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :affiliate, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class App < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :app, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class BidMatchType < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :bid_match_type, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Brand < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :brand, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Browser < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :browser, cache: 50, find_or_create: true
6
+
7
+ has_many :user_agents
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Land
2
+ class Campaign < ApplicationRecord
3
+
4
+ include TableName
5
+
6
+ lookup_by :campaign, cache: 50, find_or_create: true
7
+
8
+ has_many :attributions
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Content < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :content, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Creative < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :creative, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Device < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :device, cache: 50, find_or_create: true
6
+
7
+ has_many :user_agents
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class DeviceType < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :device_type, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Domain < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :domain, cache: 50, find_or_create: true, allow_blank: true
6
+
7
+ has_many :referers
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class EventType < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :event_type, cache: 100
6
+
7
+ has_many :events
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Experiment < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :experiment, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class HttpMethod < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :http_method, cache: 50, find_or_create: true
6
+
7
+ has_many :pageviews
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Keyword < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :keyword, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class MatchType < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :match_type, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Medium < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :medium, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class MimeType < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :mime_type, cache: 50, find_or_create: true
6
+
7
+ has_many :pageviews
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Land
2
+ class Network < ApplicationRecord
3
+ include TableName
4
+
5
+ lookup_by :network, cache: 50, find_or_create: true
6
+
7
+ has_many :attributions
8
+ end
9
+ end