Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

# Specify your gem's dependencies in rack-tracker.gemspec
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "bundler/gem_tasks"
require 'rspec/core/rake_task'

Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "rack"
require "tilt"
require "active_support/core_ext/class/attribute"
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/bing/bing.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::Bing < Rack::Tracker::Handler

class Conversion < OpenStruct
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Rack
class Tracker
module Controller
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/criteo/criteo.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::Criteo < Rack::Tracker::Handler

TRACKER_EVENTS = {
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/drift/drift.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
class Rack::Tracker::Drift < Rack::Tracker::Handler
end
1 change: 1 addition & 0 deletions lib/rack/tracker/extensions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'ostruct'

# Backport of 2.0.0 stdlib ostruct#to_h
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/facebook/facebook.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::Facebook < Rack::Tracker::Handler
class Event < OpenStruct
def write
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/facebook_pixel/facebook_pixel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::FacebookPixel < Rack::Tracker::Handler
self.position = :body
self.allowed_tracker_options = [:id]
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/go_squared/go_squared.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::GoSquared < Rack::Tracker::Handler
class VisitorName < OpenStruct
def write
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::GoogleAdwordsConversion < Rack::Tracker::Handler
class Conversion < OpenStruct
end
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/google_analytics/google_analytics.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::GoogleAnalytics < Rack::Tracker::Handler

self.allowed_tracker_options = [:cookie_domain, :user_id]
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/google_global/google_global.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::GoogleGlobal < Rack::Tracker::Handler
self.allowed_tracker_options = [:cookie_domain, :user_id,
:link_attribution, :allow_display_features, :anonymize_ip,
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/google_tag_manager/google_tag_manager.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::GoogleTagManager < Rack::Tracker::Handler

class Push < OpenStruct
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::Handler
class << self
def process_track(env, method_name, *args, &block)
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/handler_delegator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::HandlerDelegator
class << self
def handler(method_name)
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/heap/heap.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
class Rack::Tracker::Heap < Rack::Tracker::Handler
end
1 change: 1 addition & 0 deletions lib/rack/tracker/hotjar/hotjar.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
class Rack::Tracker::Hotjar < Rack::Tracker::Handler
end
1 change: 1 addition & 0 deletions lib/rack/tracker/hubspot/hubspot.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
class Rack::Tracker::Hubspot < Rack::Tracker::Handler
end
5 changes: 3 additions & 2 deletions lib/rack/tracker/javascript_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This module is extracted from Rails to provide reliable javascript escaping.
#
# @see https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/javascript_helper.rb
Expand All @@ -13,8 +14,8 @@ module Rack::Tracker::JavaScriptHelper
"'" => "\\'"
}

JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = '&#x2028;'
JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = '&#x2029;'
JS_ESCAPE_MAP[(+"\342\200\250").force_encoding(Encoding::UTF_8).encode!] = '&#x2028;'
JS_ESCAPE_MAP[(+"\342\200\251").force_encoding(Encoding::UTF_8).encode!] = '&#x2029;'

# Escapes carriage returns and single and double quotes for JavaScript segments.
#
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Rack
class Tracker
class Railtie < ::Rails::Railtie
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Rack
class Tracker
VERSION = '1.13.0'
Expand Down
1 change: 1 addition & 0 deletions lib/rack/tracker/vwo/vwo.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
class Rack::Tracker::Vwo < Rack::Tracker::Handler
end
1 change: 1 addition & 0 deletions lib/rack/tracker/zanox/zanox.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Rack::Tracker::Zanox < Rack::Tracker::Handler

# name of the handler
Expand Down
1 change: 1 addition & 0 deletions rack-tracker.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rack/tracker/version'
Expand Down
1 change: 1 addition & 0 deletions spec/benchmark/tracker_injection_benchmark.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'
require 'benchmark'

Expand Down
1 change: 1 addition & 0 deletions spec/handler/bing_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Bing do

it 'will be placed in the body' do
Expand Down
1 change: 1 addition & 0 deletions spec/handler/criteo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Criteo do

describe Rack::Tracker::Criteo::Event do
Expand Down
1 change: 1 addition & 0 deletions spec/handler/drift_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Drift do
def env
{ foo: 'bar' }
Expand Down
1 change: 1 addition & 0 deletions spec/handler/facebook_pixel_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::FacebookPixel do
def env
{ 'PIXEL_ID' => 'DYNAMIC_PIXEL_ID' }
Expand Down
1 change: 1 addition & 0 deletions spec/handler/facebook_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Facebook do
describe Rack::Tracker::Facebook::Event do

Expand Down
1 change: 1 addition & 0 deletions spec/handler/go_squared_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::GoSquared do

def env
Expand Down
1 change: 1 addition & 0 deletions spec/handler/google_adwords_conversion_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::GoogleAdwordsConversion do

def env
Expand Down
1 change: 1 addition & 0 deletions spec/handler/google_analytics_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::GoogleAnalytics do
def env
{
Expand Down
1 change: 1 addition & 0 deletions spec/handler/google_global_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::GoogleGlobal do
def env
{
Expand Down
3 changes: 2 additions & 1 deletion spec/handler/google_tag_manager_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::GoogleTagManager do

def env
Expand Down Expand Up @@ -42,7 +43,7 @@ def env
end

context 'with one line html response' do
let(:example_response) { "<html><head></head><body></body></html>" }
let(:example_response) { +"<html><head></head><body></body></html>" }

it 'will have render_head content in head tag' do
expect(subject).to match(%r{<head>.*<script>"HEAD"</script>.*</head>})
Expand Down
1 change: 1 addition & 0 deletions spec/handler/handler_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Handler do
def env
{ misc: 'foobar' }
Expand Down
1 change: 1 addition & 0 deletions spec/handler/heap_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Heap do
def env
{ foo: 'bar' }
Expand Down
1 change: 1 addition & 0 deletions spec/handler/hotjar_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Hotjar do
def env
{ foo: 'bar' }
Expand Down
1 change: 1 addition & 0 deletions spec/handler/hubspot_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Hubspot do

def env
Expand Down
1 change: 1 addition & 0 deletions spec/handler/vwo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Vwo do

def env
Expand Down
1 change: 1 addition & 0 deletions spec/handler/zanox_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker::Zanox do

describe Rack::Tracker::Zanox::Sale do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/bing_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Bing Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/criteo_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Criteo Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/drift_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe 'Drift Integration' do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/facebook_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Facebook Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/facebook_pixel_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Facebook Pixel Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/go_squared_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "GoSquared Integration" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Google Adwords Conversion Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/google_analytics_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Google Analytics Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/google_global_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Google Global Integration Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/google_tag_manager_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Google Tag Manager Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/heap_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Heap Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/hotjar_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Hotjar Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/hubspot_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Hubspot Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/rails_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Rails Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/vwo_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "VWO Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/integration/zanox_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/capybara_app_helper'

RSpec.describe "Zanox Integration" do
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

Expand Down
1 change: 1 addition & 0 deletions spec/support/capybara_app_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'support/metal_controller'

# helper to configure the middleware stack with custom handlers
Expand Down
1 change: 1 addition & 0 deletions spec/support/fake_handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class TrackAllTheThings < Rack::Tracker::Handler
def render
Tilt.new( File.join( File.dirname(__FILE__), '../fixtures/track_all_the_things.erb') ).render(self)
Expand Down
1 change: 1 addition & 0 deletions spec/support/metal_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'action_controller'

class MetalController < ActionController::Metal
Expand Down
1 change: 1 addition & 0 deletions spec/tracker/controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
TestController = Struct.new(:env) do
include Rack::Tracker::Controller

Expand Down
1 change: 1 addition & 0 deletions spec/tracker/handler_delegator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Foo = Class.new
Bar = Class.new

Expand Down
1 change: 1 addition & 0 deletions spec/tracker/handler_set_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Dummy < Rack::Tracker::Handler
end

Expand Down
5 changes: 3 additions & 2 deletions spec/tracker/javascript_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.describe Rack::Tracker do

let(:escaper) do
Expand Down Expand Up @@ -39,8 +40,8 @@
it { should escape(%(This "thing" is really\n netos')).to %(This \\"thing\\" is really\\n netos\\') }
it { should escape(%(backslash\\test)).to %(backslash\\\\test) }
it { should escape(%(dont </close> tags)).to %(dont <\\/close> tags) }
it { should escape(%(unicode \342\200\250 newline).force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2028; newline) }
it { should escape(%(unicode \342\200\251 newline).force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2029; newline) }
it { should escape((+%(unicode \342\200\250 newline)).force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2028; newline) }
it { should escape((+%(unicode \342\200\251 newline)).force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2029; newline) }

it 'works with symbols' do
expect(subject).to escape(:dimension1).to 'dimension1'
Expand Down