line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::GoogleAnalytics::Mobile; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
210733
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
71
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
170
|
|
6
|
2
|
|
|
2
|
|
8085
|
use Digest::SHA qw/hmac_sha1_hex/; |
|
2
|
|
|
|
|
18655
|
|
|
2
|
|
|
|
|
278
|
|
7
|
2
|
|
|
2
|
|
158140
|
use URI; |
|
2
|
|
|
|
|
13803
|
|
|
2
|
|
|
|
|
62
|
|
8
|
2
|
|
|
2
|
|
925
|
use URI::QueryParam; |
|
2
|
|
|
|
|
620
|
|
|
2
|
|
|
|
|
49
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1842
|
use Plack::Util::Accessor qw/base_url account secret/; |
|
2
|
|
|
|
|
494
|
|
|
2
|
|
|
|
|
14
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
1
|
|
|
1
|
1
|
17
|
my $class = shift; |
16
|
1
|
|
|
|
|
2
|
my $self; |
17
|
1
|
50
|
33
|
|
|
7
|
if (@_ == 1 && ref $_[0] eq 'HASH') { |
18
|
0
|
|
|
|
|
0
|
$self = bless {%{$_[0]}}, $class; |
|
0
|
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
} else { |
20
|
1
|
|
|
|
|
9
|
$self = bless {@_}, $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
8
|
Carp::croak "google analytics mobile beacon base_url is needed" unless $self->base_url; |
24
|
1
|
50
|
|
|
|
17
|
Carp::croak "google analytics account id is needed" unless $self->account; |
25
|
1
|
50
|
|
|
|
12
|
Carp::croak "sercret key for checksum is needed" unless $self->secret; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
7
|
$self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub image_url { |
31
|
1
|
|
|
1
|
1
|
15850
|
my $self = shift; |
32
|
1
|
|
|
|
|
3
|
my $env = shift; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
4
|
my $utmn = int(rand 0x7fffffff ); |
35
|
1
|
50
|
|
|
|
13
|
my $referer = defined $env->{HTTP_REFERER} ? $env->{HTTP_REFERER} : "-"; |
36
|
1
|
50
|
|
|
|
6
|
my $path = defined $env->{REQUEST_URI} ? $env->{REQUEST_URI} : ""; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
3
|
my $domain = ""; |
39
|
1
|
50
|
|
|
|
4
|
if ( defined $env->{HTTP_HOST} ) { |
|
|
0
|
|
|
|
|
|
40
|
1
|
|
|
|
|
4
|
$domain = $env->{HTTP_HOST}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ( defined $env->{SERVER_NAME} ) { |
43
|
0
|
|
|
|
|
0
|
$domain = $env->{SERVER_NAME}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#guid cleanup |
47
|
1
|
50
|
|
|
|
6
|
if ( $referer ne "-") { |
48
|
1
|
|
|
|
|
10
|
my $r_uri = URI->new($referer); |
49
|
1
|
|
|
|
|
114
|
$r_uri->query_param_delete('guid'); |
50
|
1
|
|
|
|
|
218
|
$referer = $r_uri->as_string; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
14
|
my $digest = substr( hmac_sha1_hex($utmn . $domain . $path, $self->secret), 16, 6 ); |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
46
|
my $url = URI->new($self->base_url); |
56
|
1
|
|
|
|
|
55
|
$url->query_form_hash({ |
57
|
|
|
|
|
|
|
utmac => $self->account, |
58
|
|
|
|
|
|
|
utmn => $utmn, |
59
|
|
|
|
|
|
|
utmhn => $domain, |
60
|
|
|
|
|
|
|
utmr => $referer, |
61
|
|
|
|
|
|
|
utmp => $path, |
62
|
|
|
|
|
|
|
cs => $digest, |
63
|
|
|
|
|
|
|
guid => 'ON', |
64
|
|
|
|
|
|
|
}); |
65
|
1
|
|
|
|
|
330
|
return $url; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |