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
80c771c9
Commit
80c771c9
authored
Mar 27, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added googla analytics id setting
parent
6bd27361
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
15 deletions
+72
-15
conf/defaults.ini
+11
-7
conf/sample.ini
+9
-6
pkg/api/index.go
+4
-0
pkg/setting/setting.go
+5
-2
src/app/services/all.js
+1
-0
src/app/services/analytics.js
+28
-0
src/views/index.html
+14
-0
No files found.
conf/defaults.ini
View file @
80c771c9
app_name
=
Grafana
app_mode
=
production
# Report anonymous usage counters to stats.grafana.org (https).
# No ip addresses are being tracked, only simple counters to track
# running instances, dashboard and error counts. It is very helpful to us.
# Change this option to false to disable reporting.
reporting-enabled
=
true
[server]
; protocol (http or https)
protocol
=
http
...
...
@@ -21,11 +15,21 @@ root_url = %(protocol)s://%(domain)s:%(http_port)s/
router_logging
=
false
; the path relative to the binary where the static (html/js/css) files are placed
static_root_path
=
public
; enable gzip
enable_gzip
=
false
;
if https protocol
;
https certs & key file
cert_file
=
cert_key
=
[analytics]
# Server reporting, sends usage counters to stats.grafana.org (https).
# No ip addresses are being tracked, only simple counters to track
# running instances, dashboard and error counts. It is very helpful to us.
# Change this option to false to disable reporting.
reporting_enabled
=
true
; Google Analytics universal tracking code, only enabled if you specify an id here
google_analytics_ua_id
=
[database]
; Either "mysql", "postgres" or "sqlite3", it's your choice
type
=
sqlite3
...
...
conf/sample.ini
View file @
80c771c9
...
...
@@ -5,12 +5,6 @@
app_mode
=
production
# Report anonymous usage counters to stats.grafana.org (https).
# No ip addresses are being tracked, only simple counters to track
# running instances, dashboard and error counts. It is very helpful to us.
# Change this option to false to disable reporting.
reporting-enabled
=
true
[server]
; protocol (http or https)
protocol
=
http
...
...
@@ -27,6 +21,15 @@ router_logging = false
static_root_path
=
public
enable_gzip
=
false
[analytics]
# Server reporting, sends usage counters to stats.grafana.org (https).
# No ip addresses are being tracked, only simple counters to track
# running instances, dashboard and error counts. It is very helpful to us.
# Change this option to false to disable reporting.
reporting_enabled
=
true
; Google Analytics universal tracking code, only enabled if you specify an id here
google_analytics_ua_id
=
[database]
; Either "mysql", "postgres" or "sqlite3", it's your choice
type
=
sqlite3
...
...
pkg/api/index.go
View file @
80c771c9
...
...
@@ -33,6 +33,10 @@ func setIndexViewData(c *middleware.Context) error {
c
.
Data
[
"AppUrl"
]
=
setting
.
AppUrl
c
.
Data
[
"AppSubUrl"
]
=
setting
.
AppSubUrl
if
setting
.
GoogleAnalyticsId
!=
""
{
c
.
Data
[
"GoogleAnalyticsId"
]
=
setting
.
GoogleAnalyticsId
}
return
nil
}
...
...
pkg/setting/setting.go
View file @
80c771c9
...
...
@@ -97,7 +97,8 @@ var (
configFiles
[]
string
ReportingEnabled
bool
ReportingEnabled
bool
GoogleAnalyticsId
string
)
func
init
()
{
...
...
@@ -235,7 +236,9 @@ func NewConfigContext(config string) {
ImagesDir
=
"data/png"
PhantomDir
=
"vendor/phantomjs"
ReportingEnabled
=
Cfg
.
Section
(
""
)
.
Key
(
"reporting-enabled"
)
.
MustBool
(
true
)
analytics
:=
Cfg
.
Section
(
"analytics"
)
ReportingEnabled
=
analytics
.
Key
(
"reporting_enabled"
)
.
MustBool
(
true
)
GoogleAnalyticsId
=
analytics
.
Key
(
"google_analytics_ua_id"
)
.
String
()
readSessionConfig
()
}
...
...
src/app/services/all.js
View file @
80c771c9
...
...
@@ -5,6 +5,7 @@ define([
'./contextSrv'
,
'./timer'
,
'./keyboardManager'
,
'./analytics'
,
'./popoverSrv'
,
'./backendSrv'
,
],
...
...
src/app/services/analytics.js
0 → 100644
View file @
80c771c9
define
([
'angular'
,
],
function
(
angular
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
service
(
'googleAnalyticsSrv'
,
function
(
$rootScope
,
$location
)
{
var
first
=
true
;
this
.
init
=
function
()
{
$rootScope
.
$on
(
'$viewContentLoaded'
,
function
()
{
// skip first
if
(
first
)
{
first
=
false
;
return
;
}
window
.
ga
(
'send'
,
'pageview'
,
{
page
:
$location
.
url
()
});
});
};
}).
run
(
function
(
googleAnalyticsSrv
)
{
if
(
window
.
ga
)
{
googleAnalyticsSrv
.
init
();
}
});
});
src/views/index.html
View file @
80c771c9
...
...
@@ -59,5 +59,19 @@
require
([
'app'
],
function
(
app
)
{
app
.
boot
();
})
</script>
[[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]]
</html>
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