Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Cto 222 mixpanel gdpr #90

Open
wants to merge 83 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
e8b7b45
remove examples
Oct 8, 2012
050e513
remove session command store
Oct 8, 2012
c2e5ad1
Make javascript_helpers mandatory
Oct 8, 2012
2842dfc
Channel events through flash instead of rendering them to the page.
Oct 8, 2012
7e6e30a
forgot to update gemspec
Oct 8, 2012
5e0df9a
add middleware
Oct 10, 2012
432106a
don't log options in a separate line
Oct 10, 2012
07f3b0a
explicitly require the middleware
Oct 10, 2012
fc6e99c
update mixpanel module
Oct 10, 2012
53958ba
re-add support for commands other than event
Oct 11, 2012
5273954
support google in the new style commands
Oct 11, 2012
6cc6676
fix middleware cookie handling
Oct 11, 2012
d489ab5
modernize crazy_egg include
Oct 16, 2012
6c24f75
Fix google event tracking value
Jan 25, 2013
e30354d
fix js decoding
Feb 27, 2013
b54806b
Support Display Advertiser
Nov 26, 2013
8c3b309
solve jquery deprecation warning
Feb 22, 2014
779cf9c
Update mixpanel implementation
Mar 25, 2014
7a99822
Merge pull request #1 from pedrocarrico/master
dsgh Mar 26, 2014
f1eaf46
Update google analytics to the new Universal Analytics version
Apr 30, 2014
62cedd3
Merge pull request #2 from pedrocarrico/master
dsgh May 6, 2014
db380aa
Add alias identity to mixpanel module
May 8, 2014
2d73feb
Merge pull request #3 from pierreozoux/master
dsgh May 9, 2014
9236c46
Fix arguments' order for google analytics tracking method.
andr3 Jun 19, 2014
070cb84
Merge pull request #4 from andr3pt/ga-events-not-configured-properly
dsgh Jun 19, 2014
77f87dd
minor: correctly indent output
Jun 30, 2014
2bb0a66
Google: support optional linkid
Jun 30, 2014
8c3c2ea
send event action as string "undefined" when action is not defined
Jul 7, 2014
598a73a
Merge pull request #5 from telmofcosta/master
dsgh Jul 9, 2014
1adb350
Add sift science module
Mar 31, 2015
be515b5
Merge pull request #6 from marionzualo/master
dsgh Mar 31, 2015
a324f41
Upgrade jquery Cookie to js cookie
Jun 9, 2015
50520db
Merge pull request #7 from pedrocarrico/upgrade-to-js-cookie
dsgh Jun 9, 2015
f861c5f
Disable robot checking
Dec 7, 2015
a5714be
Merge pull request #8 from sergiopatricio/master
dsgh Dec 7, 2015
5fce5c3
Add Google Tag Manager module
Dec 9, 2015
89dbc59
Merge pull request #9 from sergiopatricio/google-tag-manager
dsgh Dec 10, 2015
6ca6056
Cleanup track in mixpanel
Jan 6, 2016
70699ca
Enable track (page-view events) javascript
Jan 6, 2016
07619ef
Configure track (page-view events) for google
Jan 6, 2016
bd414dc
Merge pull request #10 from sergiopatricio/track
dsgh Jan 7, 2016
290b184
Enable identify option for google module
Jan 7, 2016
8fc692f
Merge pull request #11 from sergiopatricio/google-identify
dsgh Jan 8, 2016
7d659c6
Allow to send custom dimensions with google track
Jan 19, 2016
eac462a
Merge pull request #12 from sergiopatricio/google-track-with-options
dsgh Jan 29, 2016
5ee4891
Properly enable identify option for google module
Feb 2, 2016
e83a2a4
Merge pull request #13 from sergiopatricio/ga-identify-fix
dsgh Feb 2, 2016
393ccfa
Integrate GA and Optimizely
Apr 13, 2016
6b02e25
Merge pull request #14 from marionzualo/mix-opt
dsgh Apr 13, 2016
d007975
Track events in intercom
May 13, 2016
83d827a
Merge pull request #15 from marionzualo/intercom
dsgh May 13, 2016
5fb5ea6
Spelling fix
Jun 14, 2016
82b8d7c
Update intercom user after event track
Jun 14, 2016
202a8d1
Merge pull request #16 from telmofcosta/intercom-update-async-request
dsgh Jun 15, 2016
6a64ec1
Update mixpanel lib
Aug 22, 2016
a1ebeaa
Add reset method
Aug 22, 2016
cdf8774
Merge pull request #17 from Seedrs/add-reset-method
miguelfteixeira Aug 23, 2016
182139e
Fix mixpanel lib
Aug 23, 2016
b0f1010
Merge pull request #18 from Seedrs/fix-mixpanel-lib
miguelfteixeira Aug 24, 2016
16671d3
Update AdRoll code
Aug 31, 2016
1348b7f
Merge pull request #19 from Seedrs/update-adroll
Sep 1, 2016
7f6ec2e
Update adroll code again
Sep 1, 2016
7445db9
Check if intercom is defined before calling it
sergiopatricio Oct 28, 2016
af46f08
Merge pull request #20 from Seedrs/intercom-fix
sergiopatricio Oct 28, 2016
646c5f3
Add segment
Nov 15, 2016
f3be42f
Add the ability to track virtual page views
Nov 25, 2016
d23030e
Add url in segment track method
Nov 25, 2016
fc051a0
Merge pull request #21 from Seedrs/add-segment
nsorros Dec 12, 2016
a976fc0
Add options as a string in GA to be able to filter
Dec 16, 2016
837b9cf
Merge pull request #23 from Seedrs/ga-label-update
nsorros Dec 19, 2016
3ac663d
Remove intercom integration
Jan 10, 2017
8765758
Merge pull request #24 from Seedrs/remove-intercom
danielmag Jan 11, 2017
b01d941
Ignore referrer when cookie for that is present
Feb 9, 2018
71a065e
Merge pull request #26 from Seedrs/INV-1060-ignore-referrer
sergiopatricio Feb 12, 2018
5c7e628
Fix rails 5 deprecation
May 9, 2018
eb339cc
Implementing not track on Mixpanel
brizido May 24, 2018
2403cd9
Merge pull request #27 from Seedrs/CTO-222-mixpanel-gdpr
brizido May 24, 2018
11d6711
Fixing typo
brizido May 24, 2018
83224f3
Merge pull request #28 from Seedrs/CTO-222-mixpanel-gdpr
brizido May 24, 2018
d985771
Fixing issue where visitors where not being tracked
brizido May 31, 2018
9b9f868
Merge pull request #29 from Seedrs/CTO-222-mixpanel-gdpr
brizido May 31, 2018
2bb03e6
Fixing mixpanel tracking
brizido Jul 16, 2018
45a087a
Merge branch 'master' into CTO-222-mixpanel-gdpr
brizido Jul 16, 2018
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
Prev Previous commit
Next Next commit
add middleware
Duarte Henriques committed Oct 10, 2012
commit 5e0df9a8a7b42dee866ef3c424f6fb70d50dbd2c
4 changes: 4 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@ Add the following to your controllers:

analytical

Add the middleware configuration in config/application.rb:

config.middleware.use Analytical::Middleware

Add a configuration file (config/analytical.yml) to declare your API keys, like so:

production:
19 changes: 19 additions & 0 deletions app/views/application/_analytical_fire_events.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script type="text/javascript">
$(function() {
var eventsData;

try {
eventsData = $.parseJSON(($.cookie('analytical') || '').replace(/\+/g, ' ')) || [];
} catch(e) {
eventsData = [];
}

$.cookie('analytical', null, { path: '/' });
$.each(eventsData, function(index, eventData) {
var name = eventData[0],
options = eventData[1];

Analytical.event(name, options);
});
});
</script>
4 changes: 0 additions & 4 deletions lib/analytical.rb
Original file line number Diff line number Diff line change
@@ -9,10 +9,6 @@ module Analytical
def analytical(options = {})
config = Analytical.config(options[:config])
self.analytical_options = options.reverse_merge(config)

after_filter do |controller|
flash[:analytical] = controller.analytical.flash.to_json.html_safe
end
end

def self.config(path = nil)
30 changes: 17 additions & 13 deletions lib/analytical/api.rb
Original file line number Diff line number Diff line change
@@ -20,10 +20,6 @@ def initialize(options={})
@dummy_module = Analytical::Modules::DummyModule.new
end

def flash
@modules.values.map{ |m| m.events_options }.flatten(1)
end

def get_mod(name)
name = name.to_s.camelize
"Analytical::Modules::#{name}".constantize
@@ -79,16 +75,10 @@ def head_prepend_javascript

def head_append_javascript
js = [
init_javascript(:head_append)
init_javascript(:head_append),
render_js_partial("analytical_javascript")
]

if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('3.1.0') # Rails 3.1 lets us override views in engines
js << options[:controller].send(:render_to_string, :partial=>'analytical_javascript') if options[:controller]
else # All other rails
_partial_path = Pathname.new(__FILE__).dirname.join('..', '..', 'app/views/application', '_analytical_javascript.html.erb').to_s
js << options[:controller].send(:render_to_string, :file=>_partial_path, :layout=>false) if options[:controller]
end

js.delete_if{|s| s.blank?}.join("\n")
end

@@ -98,11 +88,25 @@ def body_prepend_javascript
[init_javascript(:body_prepend)].delete_if{|s| s.blank?}.join("\n")
end
def body_append_javascript
[init_javascript(:body_append)].delete_if{|s| s.blank?}.join("\n")
js = [
init_javascript(:body_append),
render_js_partial("analytical_fire_events")
]

js.delete_if{|s| s.blank?}.join("\n")
end

private

def render_js_partial(name)
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('3.1.0') # Rails 3.1 lets us override views in engines
options[:controller].send(:render_to_string, :partial=> name) if options[:controller]
else # All other rails
_partial_path = Pathname.new(__FILE__).dirname.join('..', '..', 'app/views/application', "_#{name}.html.erb").to_s
options[:controller].send(:render_to_string, :file=>_partial_path, :layout=>false) if options[:controller]
end
end

def process_command(command, *args)
@modules.values.each do |m|
m.queue command, *args
26 changes: 26 additions & 0 deletions lib/analytical/middleware.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Analytical
class Middleware

def initialize(app)
@app = app
end

def call(env)
status, headers, body = @app.call(env)

new_events_data = env["analytical"]
if new_events_data
response = Rack::Response.new(body, status, headers)
cookies = env["rack.cookies"] || {}

events_data = (JSON(cookies["analytical"]) if cookies["analytical"]) || [] rescue []
events_data.concat(new_events_data)
response.set_cookie("analytical", { :value => events_data.to_json, :path => "/" })
response.finish
else
[status, headers, body]
end
end

end
end
12 changes: 5 additions & 7 deletions lib/analytical/modules/base.rb
Original file line number Diff line number Diff line change
@@ -46,17 +46,15 @@ def queue(*args)
if args.first==:identify
@command_store.unshift args
else
# we only care about events, all other commands will be removed without having effect
if args[0] == :event
@options[:controller].env["analytical"] ||= []
@options[:controller].env["analytical"] << [args[1], args[2]]
end
@command_store << args
end
end

# we only care about events, all other commands will be removed without having effect
def events_options
result = @command_store.commands.select{ |command| command[0] == :event }.map{ |command| [command[1], command[2]] }
@command_store.flush
result
end

def init_location?(location)
if @tracking_command_location.is_a?(Array)
@tracking_command_location.map { |item|item.to_sym }.include?(location.to_sym)