line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Tracking::Data; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
60928
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
120
|
|
4
|
5
|
|
|
5
|
|
14
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
132
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
14
|
use base 'Class::Accessor::Fast'; |
|
5
|
|
|
|
|
4
|
|
|
5
|
|
|
|
|
642
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
1956
|
use Digest::MD5 qw(md5_hex); |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
230
|
|
11
|
5
|
|
|
5
|
|
2042
|
use Math::BaseCnv 'dec'; |
|
5
|
|
|
|
|
144605
|
|
|
5
|
|
|
|
|
1507
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @TRACKING_PROPERTIES = qw( |
14
|
|
|
|
|
|
|
hostname |
15
|
|
|
|
|
|
|
request_uri |
16
|
|
|
|
|
|
|
remote_ip |
17
|
|
|
|
|
|
|
user_agent |
18
|
|
|
|
|
|
|
referer |
19
|
|
|
|
|
|
|
browser_language |
20
|
|
|
|
|
|
|
timestamp |
21
|
|
|
|
|
|
|
encoding |
22
|
|
|
|
|
|
|
screen_color_depth |
23
|
|
|
|
|
|
|
screen_resolution |
24
|
|
|
|
|
|
|
visitor_id |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
pdf_support |
27
|
|
|
|
|
|
|
cookie_support |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
flash_version |
30
|
|
|
|
|
|
|
java_version |
31
|
|
|
|
|
|
|
quicktime_version |
32
|
|
|
|
|
|
|
realplayer_version |
33
|
|
|
|
|
|
|
mediaplayer_version |
34
|
|
|
|
|
|
|
gears_version |
35
|
|
|
|
|
|
|
silverlight_version |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( |
39
|
|
|
|
|
|
|
@TRACKING_PROPERTIES, |
40
|
|
|
|
|
|
|
'_tracking', |
41
|
|
|
|
|
|
|
'_gen_new_visitor_id', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
45
|
9
|
|
|
9
|
1
|
2209
|
my $class = shift; |
46
|
9
|
|
|
|
|
77
|
my $self = $class->SUPER::new({ |
47
|
|
|
|
|
|
|
'timestamp' => time(), |
48
|
|
|
|
|
|
|
@_ |
49
|
|
|
|
|
|
|
}); |
50
|
|
|
|
|
|
|
|
51
|
9
|
|
|
|
|
74
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub as_hash { |
55
|
2
|
|
|
2
|
1
|
16
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return { |
58
|
22
|
|
|
|
|
64
|
map { $_ => $self->$_ } |
59
|
2
|
|
|
|
|
5
|
grep { defined $self->$_ } |
|
40
|
|
|
|
|
149
|
|
60
|
|
|
|
|
|
|
@TRACKING_PROPERTIES |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub from_hash { |
65
|
5
|
|
|
5
|
1
|
9
|
my $class = shift; |
66
|
5
|
|
|
|
|
7
|
my $data = shift; |
67
|
|
|
|
|
|
|
|
68
|
5
|
|
|
|
|
14
|
my $self = $class->new; |
69
|
5
|
|
|
|
|
13
|
foreach my $property_name (@TRACKING_PROPERTIES) { |
70
|
|
|
|
|
|
|
$self->{$property_name} = $data->{$property_name} |
71
|
100
|
100
|
|
|
|
183
|
if (exists $data->{$property_name}); |
72
|
|
|
|
|
|
|
} |
73
|
5
|
|
33
|
|
|
18
|
$self->{'timestamp'} ||= time(); |
74
|
|
|
|
|
|
|
|
75
|
5
|
|
|
|
|
11
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub new_visitor_id { |
79
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
3
|
my $gen_new_visitor_id = $self->_gen_new_visitor_id; |
82
|
1
|
50
|
|
|
|
5
|
return $gen_new_visitor_id->() |
83
|
|
|
|
|
|
|
if $gen_new_visitor_id; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
4
|
$self->visitor_id(substr(dec(md5_hex($self->user_agent.int(rand(0x7fffffff)))),0,32)); |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
4518
|
return $self; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub full_request_url { |
91
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
92
|
2
|
|
|
|
|
9
|
return 'http://'.$self->hostname.$self->request_uri; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 NAME |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
WWW::Tracking::Data - web tracking data object |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SYNOPSIS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $tracking_data = WWW::Tracking::Data->new( |
107
|
|
|
|
|
|
|
hostname => 'example.com', |
108
|
|
|
|
|
|
|
request_uri => '/path', |
109
|
|
|
|
|
|
|
remote_ip => '1.2.3.4', |
110
|
|
|
|
|
|
|
user_agent => 'SomeWebBrowser', |
111
|
|
|
|
|
|
|
referer => 'http://search/?q=example', |
112
|
|
|
|
|
|
|
browser_language => 'de-AT', |
113
|
|
|
|
|
|
|
timestamp => 1314712280, |
114
|
|
|
|
|
|
|
java_version => undef, |
115
|
|
|
|
|
|
|
encoding => 'UTF-8', |
116
|
|
|
|
|
|
|
screen_color_depth => '24' |
117
|
|
|
|
|
|
|
screen_resolution => '1024x768', |
118
|
|
|
|
|
|
|
flash_version => '9.0', |
119
|
|
|
|
|
|
|
visitor_id => '202cb962ac59075b964b07152d234b70', |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Simple data object for web tracking that allows plugins to add different |
125
|
|
|
|
|
|
|
serialization and deserialization methods. |
126
|
|
|
|
|
|
|
See C<WWW::Tracking::Data::Plugin::*> namespace. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 PROPERTIES |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
hostname |
131
|
|
|
|
|
|
|
request_uri |
132
|
|
|
|
|
|
|
remote_ip |
133
|
|
|
|
|
|
|
user_agent |
134
|
|
|
|
|
|
|
referer |
135
|
|
|
|
|
|
|
browser_language |
136
|
|
|
|
|
|
|
timestamp |
137
|
|
|
|
|
|
|
encoding |
138
|
|
|
|
|
|
|
screen_color_depth |
139
|
|
|
|
|
|
|
screen_resolution |
140
|
|
|
|
|
|
|
visitor_id |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
pdf_support |
143
|
|
|
|
|
|
|
cookie_support |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
flash_version |
146
|
|
|
|
|
|
|
java_version |
147
|
|
|
|
|
|
|
quicktime_version |
148
|
|
|
|
|
|
|
realplayer_version |
149
|
|
|
|
|
|
|
mediaplayer_version |
150
|
|
|
|
|
|
|
gears_version |
151
|
|
|
|
|
|
|
silverlight_version |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 METHODS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 new() |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Object constructor. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 as_hash() |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Clone the data and return as hash. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 from_hash($data) |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Create new L<WWW::Tracking::Data> object from has hash. Adds current |
166
|
|
|
|
|
|
|
C<timestamp> if not provided |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 as_*() and from_*() |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
These functions are injected into L<WWW::Tracking::Data> namespace |
171
|
|
|
|
|
|
|
via plugins. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 new_visitor_id() |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Will generate new random visitor id and store it in C<visitor_id> object |
176
|
|
|
|
|
|
|
property. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 full_request_url() |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Returns string with request URL that includes protocol, hostname and path. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 SEE ALSO |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L<WWW::Tracking::Data::Plugin::*> namespace. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 AUTHOR |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Jozef Kutej |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |