piwik_analytics_with_user 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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +38 -0
- data/Rakefile +23 -0
- data/app/views/piwik_analytics_with_user/piwik_tracking_tag.html.erb +15 -0
- data/app/views/piwik_analytics_with_user/piwik_tracking_tag_async.html.erb +22 -0
- data/init.rb +1 -0
- data/lib/generators/piwik_analytics_with_user.rb +7 -0
- data/lib/generators/piwik_analytics_with_user/install/install_generator.rb +12 -0
- data/lib/generators/piwik_analytics_with_user/install/templates/config/piwik.yml +33 -0
- data/lib/piwik_analytics_with_user.rb +13 -0
- data/lib/piwik_analytics_with_user/configuration.rb +74 -0
- data/lib/piwik_analytics_with_user/engine.rb +20 -0
- data/lib/piwik_analytics_with_user/helpers.rb +18 -0
- data/lib/piwik_analytics_with_user/init.rb +1 -0
- data/piwik_analytics_with_user.gemspec +24 -0
- data/test/test_helper.rb +3 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 004aacaba24d454a278dac7e88b69e445758c6ac
|
4
|
+
data.tar.gz: 66e111a5c6375b845616f9848b10a83e3760af2c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 981dd8b428b84af7f20786e321cb12e4f525ce913a223512659fefcad726f0fdf34728dbc6f74cb1e20837f015bfe379466ba8bc622cea9b61a9213738f58345
|
7
|
+
data.tar.gz: 0c0258d9c74552ef7d9b25a2fd28b0ccd7e69c75a2426f5c1f1af08c2ee4c40f3209aff1a990d6f67c3dbba22225dc0f05a4220dbec19aec12fde580f530ae62
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
= PiwikAnalytics
|
2
|
+
|
3
|
+
**Note:** This Gem has undergone a major rewrite in 1.x compared to 0.9.x.
|
4
|
+
|
5
|
+
The piwik_analytics gem provides an easy way to include Piwik into your application.
|
6
|
+
By default it will output the synchronous piwik tracking code for every page
|
7
|
+
(given that it is configured correctly).
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
Add `piwik_analytics` to Gemfile:
|
12
|
+
|
13
|
+
gem 'piwik_analytics', '~> 1.0.0'
|
14
|
+
|
15
|
+
Run the generator:
|
16
|
+
|
17
|
+
rails g piwik_analytics:install
|
18
|
+
|
19
|
+
This will install a piwik.yml configuration file into the `config` directory
|
20
|
+
of your application.
|
21
|
+
|
22
|
+
|
23
|
+
== Configuration
|
24
|
+
|
25
|
+
Open up `config/piwik.yml` and edit the settings. Each setting is described in
|
26
|
+
the config file itself.
|
27
|
+
|
28
|
+
== Usage
|
29
|
+
|
30
|
+
Inside your `application.html.erb` (or haml, slim) simply add
|
31
|
+
|
32
|
+
<%= piwik_tracking_tag %>
|
33
|
+
|
34
|
+
Enjoy :)
|
35
|
+
|
36
|
+
|
37
|
+
= Licence
|
38
|
+
Copyright(c) 2010-2012 Fabian Becker, released under MIT licence.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rdoc/task'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the piwik_analytics plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the piwik_analytics plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'PiwikAnalyticsWithUser'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!-- Piwik -->
|
2
|
+
<script type="text/javascript">
|
3
|
+
var pkBaseURL = (("https:" == document.location.protocol) ? "https://<%= url %>/" : "http://<%= url %>/");
|
4
|
+
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
|
5
|
+
</script><script type="text/javascript">
|
6
|
+
try {
|
7
|
+
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", <%= id_site %>);
|
8
|
+
<% unless id_user.nil? %>
|
9
|
+
piwikTracker.setUserId('<%= id_user %>');
|
10
|
+
<%end%>
|
11
|
+
piwikTracker.trackPageView();
|
12
|
+
piwikTracker.enableLinkTracking();
|
13
|
+
} catch( err ) {}
|
14
|
+
</script>
|
15
|
+
<!-- End Piwik Tag -->
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!-- Piwik -->
|
2
|
+
<script type="text/javascript">
|
3
|
+
var _paq = _paq || [];
|
4
|
+
<% unless id_user.nil? %>
|
5
|
+
_paq.push(['setUserId', '<%=id_user%>']);
|
6
|
+
<%end%>
|
7
|
+
(function(){
|
8
|
+
var u=(("https:" == document.location.protocol) ? "https://<%= url %>/" : "http://<%= url %>/");
|
9
|
+
_paq.push(['setSiteId', <%= id_site %>]);
|
10
|
+
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
11
|
+
_paq.push(['trackPageView']);
|
12
|
+
var d=document,
|
13
|
+
g=d.createElement('script'),
|
14
|
+
s=d.getElementsByTagName('script')[0];
|
15
|
+
g.type='text/javascript';
|
16
|
+
g.defer=true;
|
17
|
+
g.async=true;
|
18
|
+
g.src=u+'piwik.js';
|
19
|
+
s.parentNode.insertBefore(g,s);
|
20
|
+
})();
|
21
|
+
</script>
|
22
|
+
<!-- End Piwik Tag -->
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/lib/piwik_analytics_with_user"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module PiwikAnalyticsWithUser
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
def self.source_root
|
5
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
6
|
+
end
|
7
|
+
def copy_config_file
|
8
|
+
template 'config/piwik.yml'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Configuration:
|
2
|
+
#
|
3
|
+
# disabled
|
4
|
+
# false if tracking tag should be shown
|
5
|
+
# use_async
|
6
|
+
# Set to true if you want to use asynchronous tracking
|
7
|
+
# url
|
8
|
+
# The url of your piwik instance (e.g. localhost/piwik/
|
9
|
+
# id_site
|
10
|
+
# The id of your website inside Piwik
|
11
|
+
#
|
12
|
+
production:
|
13
|
+
piwik:
|
14
|
+
id_site: 1
|
15
|
+
url: localhost
|
16
|
+
use_async: false
|
17
|
+
disabled: false
|
18
|
+
|
19
|
+
development:
|
20
|
+
piwik:
|
21
|
+
id_site: 1
|
22
|
+
url: localhost
|
23
|
+
disabled: true
|
24
|
+
use_async: false
|
25
|
+
hostname: localhost
|
26
|
+
|
27
|
+
test:
|
28
|
+
piwik:
|
29
|
+
id_site: 1
|
30
|
+
url: localhost
|
31
|
+
disabled: true
|
32
|
+
use_async: false
|
33
|
+
hostname: localhost
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'piwik_analytics_with_user', 'configuration')
|
2
|
+
|
3
|
+
module PiwikAnalyticsWithUser
|
4
|
+
require 'piwik_analytics_with_user/engine' if defined?(Rails)
|
5
|
+
|
6
|
+
class <<self
|
7
|
+
attr_writer :configuration
|
8
|
+
|
9
|
+
def configuration
|
10
|
+
@configuration ||= PiwikAnalyticsWithUser::Configuration.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
module PiwikAnalyticsWithUser
|
3
|
+
class Configuration
|
4
|
+
|
5
|
+
#
|
6
|
+
# The url of the Piwik instance
|
7
|
+
# Defaults to localhost
|
8
|
+
#
|
9
|
+
def url
|
10
|
+
@url ||= (user_configuration_from_key('url') || 'localhost')
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# The ID of the tracked website
|
15
|
+
# Defaults to 1
|
16
|
+
#
|
17
|
+
def id_site
|
18
|
+
@id_site ||= (user_configuration_from_key('id_site') || 1)
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Whether or not to use the async tracking
|
23
|
+
# Defaults to false
|
24
|
+
#
|
25
|
+
def use_async?
|
26
|
+
@use_async ||= (user_configuration_from_key('use_async') || false)
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Whether or not to disable Piwik.
|
31
|
+
# Defaults to false.
|
32
|
+
#
|
33
|
+
def disabled?
|
34
|
+
@disabled ||= (user_configuration_from_key('disabled') || false)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
#
|
40
|
+
# return a specific key from the user configuration in config/piwik.yml
|
41
|
+
#
|
42
|
+
# ==== Returns
|
43
|
+
#
|
44
|
+
# Mixed:: requested_key or nil
|
45
|
+
#
|
46
|
+
def user_configuration_from_key( *keys )
|
47
|
+
keys.inject(user_configuration) do |hash, key|
|
48
|
+
hash[key] if hash
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Memoized hash of configuration options for the current Rails environment
|
54
|
+
# as specified in config/piwik.yml
|
55
|
+
#
|
56
|
+
# ==== Returns
|
57
|
+
#
|
58
|
+
# Hash:: configuration options for current environment
|
59
|
+
#
|
60
|
+
def user_configuration
|
61
|
+
@user_configuration ||= begin
|
62
|
+
path = File.join(::Rails.root, 'config', 'piwik.yml')
|
63
|
+
if File.exist?(path)
|
64
|
+
File.open(path) do |file|
|
65
|
+
processed = ERB.new(file.read).result
|
66
|
+
YAML.load(processed)[::Rails.env]['piwik']
|
67
|
+
end
|
68
|
+
else
|
69
|
+
{}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# PiwikAnalytics
|
2
|
+
require 'active_support'
|
3
|
+
|
4
|
+
module PiwikAnalyticsWithUser
|
5
|
+
|
6
|
+
class Piwik < Rails::Engine
|
7
|
+
engine_name :piwik_analytics_with_user
|
8
|
+
|
9
|
+
paths["app/views"]
|
10
|
+
|
11
|
+
generators do
|
12
|
+
load "generators/piwik_analytics_with_user.rb"
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer "piwik_analytics.init", :before=> :load_config_initializers do
|
16
|
+
require "piwik_analytics_with_user/helpers"
|
17
|
+
load "piwik_analytics_with_user/init.rb"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PiwikAnalyticsWithUser
|
2
|
+
module Helpers
|
3
|
+
def piwik_tracking_tag(id_user = nil)
|
4
|
+
config = PiwikAnalyticsWithUser.configuration
|
5
|
+
return if config.disabled?
|
6
|
+
|
7
|
+
if config.use_async?
|
8
|
+
file = "piwik_analytics_with_user/piwik_tracking_tag_async"
|
9
|
+
else
|
10
|
+
file = "piwik_analytics_with_user/piwik_tracking_tag"
|
11
|
+
end
|
12
|
+
render({
|
13
|
+
:file => file,
|
14
|
+
:locals => {:url => config.url, :id_site => config.id_site, :id_user => id_user}
|
15
|
+
})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ActionView::Base.send :include, PiwikAnalyticsWithUser::Helpers
|
@@ -0,0 +1,24 @@
|
|
1
|
+
spec = Gem::Specification.new do |s|
|
2
|
+
s.name = 'piwik_analytics_with_user'
|
3
|
+
s.version = '1.1'
|
4
|
+
s.date = Time.now.strftime "%Y-%m-%d"
|
5
|
+
s.author = 'Pawel Potasiewicz'
|
6
|
+
s.email = 'web.potasiewicz@gmail.com'
|
7
|
+
s.homepage = 'https://github.com/ppotasiewicz/piwik_analytics.git'
|
8
|
+
s.summary = "[Rails] Easily include Piwik tracking with user id in your Rails application."
|
9
|
+
|
10
|
+
s.description = <<-DESC
|
11
|
+
The piwik_analytics gem provides an easy way to include Piwik into your application.
|
12
|
+
By default it will output the synchronous piwik tracking code for every page
|
13
|
+
(given that it is configured correctly).
|
14
|
+
DESC
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'rails', '>= 3.0.0'
|
21
|
+
s.add_dependency 'actionpack'
|
22
|
+
s.add_dependency 'activesupport'
|
23
|
+
end
|
24
|
+
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: piwik_analytics_with_user
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pawel Potasiewicz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: " The piwik_analytics gem provides an easy way to include Piwik into
|
56
|
+
your application.\n By default it will output the synchronous piwik tracking
|
57
|
+
code for every page\n (given that it is configured correctly). \n"
|
58
|
+
email: web.potasiewicz@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.rdoc
|
65
|
+
- Rakefile
|
66
|
+
- app/views/piwik_analytics_with_user/piwik_tracking_tag.html.erb
|
67
|
+
- app/views/piwik_analytics_with_user/piwik_tracking_tag_async.html.erb
|
68
|
+
- init.rb
|
69
|
+
- lib/generators/piwik_analytics_with_user.rb
|
70
|
+
- lib/generators/piwik_analytics_with_user/install/install_generator.rb
|
71
|
+
- lib/generators/piwik_analytics_with_user/install/templates/config/piwik.yml
|
72
|
+
- lib/piwik_analytics_with_user.rb
|
73
|
+
- lib/piwik_analytics_with_user/configuration.rb
|
74
|
+
- lib/piwik_analytics_with_user/engine.rb
|
75
|
+
- lib/piwik_analytics_with_user/helpers.rb
|
76
|
+
- lib/piwik_analytics_with_user/init.rb
|
77
|
+
- piwik_analytics_with_user.gemspec
|
78
|
+
- test/test_helper.rb
|
79
|
+
homepage: https://github.com/ppotasiewicz/piwik_analytics.git
|
80
|
+
licenses: []
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.2.2
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: "[Rails] Easily include Piwik tracking with user id in your Rails application."
|
102
|
+
test_files:
|
103
|
+
- test/test_helper.rb
|