Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
902cf5f8
Commit
902cf5f8
authored
Feb 15, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(): google analytics fix
parent
bd010289
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
22 deletions
+23
-22
pkg/api/frontendsettings.go
+1
-0
public/app/core/services/analytics.js
+22
-10
public/views/index.html
+0
-12
No files found.
pkg/api/frontendsettings.go
View file @
902cf5f8
...
...
@@ -141,6 +141,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
"authProxyEnabled"
:
setting
.
AuthProxyEnabled
,
"ldapEnabled"
:
setting
.
LdapEnabled
,
"alertingEnabled"
:
setting
.
AlertingEnabled
,
"googleAnalyticsId"
:
setting
.
GoogleAnalyticsId
,
"buildInfo"
:
map
[
string
]
interface
{}{
"version"
:
setting
.
BuildVersion
,
"commit"
:
setting
.
BuildCommit
,
...
...
public/app/core/services/analytics.js
View file @
902cf5f8
define
([
'angular'
,
'../core_module'
,
'jquery'
,
'app/core/core_module'
,
'app/core/config'
,
],
function
(
angular
,
coreModule
)
{
function
(
angular
,
$
,
coreModule
,
config
)
{
'use strict'
;
coreModule
.
default
.
service
(
'googleAnalyticsSrv'
,
function
(
$rootScope
,
$location
)
{
var
first
=
true
;
function
gaInit
()
{
$
.
getScript
(
'https://www.google-analytics.com/analytics.js'
);
// jQuery shortcut
var
ga
=
window
.
ga
=
window
.
ga
||
function
()
{
(
ga
.
q
=
ga
.
q
||
[]).
push
(
arguments
);
};
ga
.
l
=
+
new
Date
;
ga
(
'create'
,
config
.
googleAnalyticsId
,
'auto'
);
return
ga
;
}
this
.
init
=
function
()
{
$rootScope
.
$on
(
'$viewContentLoaded'
,
function
()
{
// skip first
if
(
first
)
{
first
=
false
;
return
;
}
window
.
ga
(
'send'
,
'pageview'
,
{
page
:
$location
.
url
()
}
);
var
track
=
{
page
:
$location
.
url
()
};
var
ga
=
window
.
ga
||
gaInit
()
;
ga
(
'set'
,
track
);
ga
(
'send'
,
'pageview'
);
});
};
}).
run
(
function
(
googleAnalyticsSrv
)
{
if
(
window
.
ga
)
{
if
(
config
.
googleAnalyticsId
)
{
googleAnalyticsSrv
.
init
();
}
});
});
public/views/index.html
View file @
902cf5f8
...
...
@@ -91,18 +91,6 @@
<script
src=
"[[.AppSubUrl]]/public/app/boot.js"
></script>
<!-- endbuild -->
[[if .GoogleAnalyticsId]]
<script>
(
function
(
i
,
s
,
o
,
g
,
r
,
a
,
m
){
i
[
'GoogleAnalyticsObject'
]
=
r
;
i
[
r
]
=
i
[
r
]
||
function
(){
(
i
[
r
].
q
=
i
[
r
].
q
||
[]).
push
(
arguments
)},
i
[
r
].
l
=
1
*
new
Date
();
a
=
s
.
createElement
(
o
),
m
=
s
.
getElementsByTagName
(
o
)[
0
];
a
.
async
=
1
;
a
.
src
=
g
;
m
.
parentNode
.
insertBefore
(
a
,
m
)
})(
window
,
document
,
'script'
,
'//www.google-analytics.com/analytics.js'
,
'ga'
);
ga
(
'create'
,
'[[.GoogleAnalyticsId]]'
,
'auto'
);
ga
(
'send'
,
'pageview'
);
</script>
[[end]]
[[if .GoogleTagManagerId]]
<script>
dataLayer
=
[{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment