motally 1.0.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.
- data/Manifest.txt +4 -0
- data/README +16 -0
- data/Rakefile +13 -0
- data/lib/motally.rb +93 -0
- metadata +58 -0
data/Manifest.txt
ADDED
data/README
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Setting up Motally tracker on Ruby on Rails
|
2
|
+
|
3
|
+
1. Install Motally gem from RubyForge:
|
4
|
+
|
5
|
+
sudo gem install motally
|
6
|
+
|
7
|
+
2. Add the following code snippet to app/config/environment.rb
|
8
|
+
|
9
|
+
require 'motally'
|
10
|
+
Motally::config do |m|
|
11
|
+
m.site_key = 'INSERT_SITE_KEY'
|
12
|
+
end
|
13
|
+
|
14
|
+
3. Insert the following code snippet to the corresponding helper or view of the pages that you want to track
|
15
|
+
|
16
|
+
<% Motally::track(request, session[:session_id]) %>
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hoe'
|
3
|
+
require './lib/motally.rb'
|
4
|
+
|
5
|
+
Hoe.new('motally', Motally::GEM_VERSION) do |p|
|
6
|
+
p.rubyforge_name = 'motally'
|
7
|
+
p.summary = 'Motally tracker package RoR version. It is used to track websites' statistics.'
|
8
|
+
p.author = 'Motally'
|
9
|
+
p.email = 'support@motally.com'
|
10
|
+
p.url = 'http://www.motally.com/'
|
11
|
+
p.description = 'Motally tracker package RoR version. It is used to track websites' statistics.'
|
12
|
+
p.developer('Motally', 'support@motally.com')
|
13
|
+
end
|
data/lib/motally.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'md5'
|
3
|
+
|
4
|
+
# This RoR module is provide by Motally. Please see README.txt file for instructions.
|
5
|
+
module Motally
|
6
|
+
|
7
|
+
GEM_VERSION = '1.0.1'
|
8
|
+
|
9
|
+
# Motally track url, package version and timeout length
|
10
|
+
MOTALLY_URL = URI.parse('http://track.motally.com/m/t')
|
11
|
+
PACKAGE_VERSION = 'ror.20091015'
|
12
|
+
DEFAULT_TIMEOUT = 1.0
|
13
|
+
|
14
|
+
def self.track(request, session_id)
|
15
|
+
|
16
|
+
site_key = Motally::Defaults.site_key
|
17
|
+
|
18
|
+
# get necessary environment variables
|
19
|
+
motally_headers = ''
|
20
|
+
request.env.each { |key, value|
|
21
|
+
if key.include? 'HTTP_'
|
22
|
+
motally_headers += key + "=" + value + "&"
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
# build post information
|
27
|
+
|
28
|
+
# Explanation of Optional fields
|
29
|
+
# "e" - the environment - options: "prod", "dev"
|
30
|
+
# Default is "prod" if left blank
|
31
|
+
# Currently only production values will be displayed in reports.
|
32
|
+
# Subsquent versions of the reporting will allow viewing of stats marked on the development site
|
33
|
+
#
|
34
|
+
# "mu" - markup language - options: "xhtml", "wml", "chtml"
|
35
|
+
# Default is blank
|
36
|
+
# Markup doesn't affect the stats tracked
|
37
|
+
#
|
38
|
+
# "k" - cookie flag - options: "1" = enable, "0" = disable
|
39
|
+
# Default is disabled if left blank
|
40
|
+
# If used, placement of code is important:
|
41
|
+
# "echo motallyTrack($motally_params)" needs to be called before any content is written to the output stream
|
42
|
+
# Cookies are sent as part of the header and need to be sent prior to content
|
43
|
+
#
|
44
|
+
# "u" - unique user id - options: free-form, site defined id
|
45
|
+
# Default is blank
|
46
|
+
# Site publisher can pass any String that uniquely identifies the user to aid in stats reporting
|
47
|
+
#
|
48
|
+
# "t" - track id - options: free-form, site defined id
|
49
|
+
# Default is blank
|
50
|
+
# Site publisher can define an id to further identify this particular hit
|
51
|
+
# For example a particular event occured on this page vs other versions of the same page
|
52
|
+
motally_post = {
|
53
|
+
's' => site_key, # "nl7lq3ms",
|
54
|
+
'v' => PACKAGE_VERSION,
|
55
|
+
'm' => "live",
|
56
|
+
'e' => "",
|
57
|
+
'mu'=> "", #'k' => "1",
|
58
|
+
't' => "",
|
59
|
+
'u' => "",
|
60
|
+
'a' => request.env['HTTP_USER_AGENT'],
|
61
|
+
'p' => request.env['REQUEST_URI'],
|
62
|
+
'r' => request.env['HTTP_REFERER'], #.empty? ? '' : request.env['HTTP_REFERER'],
|
63
|
+
'q' => request.env['QUERY_STRING'],
|
64
|
+
'i' => request.env['remote_ADDR'],
|
65
|
+
'si'=> Digest::MD5.hexdigest(session_id), #.empty? ? '' : session[:session_id]),
|
66
|
+
'c' => motally_headers
|
67
|
+
}
|
68
|
+
|
69
|
+
# send information via post method
|
70
|
+
req = Net::HTTP::Post.new(MOTALLY_URL.path)
|
71
|
+
req.set_form_data(motally_post)
|
72
|
+
con = Net::HTTP.new(MOTALLY_URL.host, MOTALLY_URL.port)
|
73
|
+
con.read_timeout = DEFAULT_TIMEOUT
|
74
|
+
con.open_timeout = DEFAULT_TIMEOUT
|
75
|
+
response = con.start {|http| http.request(req)}
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
# used for setting up default request information
|
80
|
+
def self.config
|
81
|
+
yield Motally::Defaults
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
class Defaults
|
87
|
+
class << self
|
88
|
+
attr_accessor :site_key
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motally
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Motally
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-23 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Motally tracker package RoR version. It is used to track websites' statistics.
|
17
|
+
email: support@motally.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README
|
26
|
+
- Manifest.txt
|
27
|
+
- Rakefile
|
28
|
+
- lib/motally.rb
|
29
|
+
has_rdoc: false
|
30
|
+
homepage: http://www.motally.com/
|
31
|
+
licenses: []
|
32
|
+
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
version:
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
requirements: []
|
51
|
+
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.3.2
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Motally tracker package RoR version. It is used to track websites' statistics.
|
57
|
+
test_files: []
|
58
|
+
|