mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added googla analytics id setting
This commit is contained in:
parent
6bd2736116
commit
80c771c945
@ -1,12 +1,6 @@
|
|||||||
app_name = Grafana
|
app_name = Grafana
|
||||||
app_mode = production
|
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]
|
[server]
|
||||||
; protocol (http or https)
|
; protocol (http or https)
|
||||||
protocol = http
|
protocol = http
|
||||||
@ -21,11 +15,21 @@ root_url = %(protocol)s://%(domain)s:%(http_port)s/
|
|||||||
router_logging = false
|
router_logging = false
|
||||||
; the path relative to the binary where the static (html/js/css) files are placed
|
; the path relative to the binary where the static (html/js/css) files are placed
|
||||||
static_root_path = public
|
static_root_path = public
|
||||||
|
; enable gzip
|
||||||
enable_gzip = false
|
enable_gzip = false
|
||||||
; if https protocol
|
; https certs & key file
|
||||||
cert_file =
|
cert_file =
|
||||||
cert_key =
|
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]
|
[database]
|
||||||
; Either "mysql", "postgres" or "sqlite3", it's your choice
|
; Either "mysql", "postgres" or "sqlite3", it's your choice
|
||||||
type = sqlite3
|
type = sqlite3
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
|
|
||||||
app_mode = production
|
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]
|
[server]
|
||||||
; protocol (http or https)
|
; protocol (http or https)
|
||||||
protocol = http
|
protocol = http
|
||||||
@ -27,6 +21,15 @@ router_logging = false
|
|||||||
static_root_path = public
|
static_root_path = public
|
||||||
enable_gzip = false
|
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]
|
[database]
|
||||||
; Either "mysql", "postgres" or "sqlite3", it's your choice
|
; Either "mysql", "postgres" or "sqlite3", it's your choice
|
||||||
type = sqlite3
|
type = sqlite3
|
||||||
|
@ -33,6 +33,10 @@ func setIndexViewData(c *middleware.Context) error {
|
|||||||
c.Data["AppUrl"] = setting.AppUrl
|
c.Data["AppUrl"] = setting.AppUrl
|
||||||
c.Data["AppSubUrl"] = setting.AppSubUrl
|
c.Data["AppSubUrl"] = setting.AppSubUrl
|
||||||
|
|
||||||
|
if setting.GoogleAnalyticsId != "" {
|
||||||
|
c.Data["GoogleAnalyticsId"] = setting.GoogleAnalyticsId
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,8 @@ var (
|
|||||||
|
|
||||||
configFiles []string
|
configFiles []string
|
||||||
|
|
||||||
ReportingEnabled bool
|
ReportingEnabled bool
|
||||||
|
GoogleAnalyticsId string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -235,7 +236,9 @@ func NewConfigContext(config string) {
|
|||||||
ImagesDir = "data/png"
|
ImagesDir = "data/png"
|
||||||
PhantomDir = "vendor/phantomjs"
|
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()
|
readSessionConfig()
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ define([
|
|||||||
'./contextSrv',
|
'./contextSrv',
|
||||||
'./timer',
|
'./timer',
|
||||||
'./keyboardManager',
|
'./keyboardManager',
|
||||||
|
'./analytics',
|
||||||
'./popoverSrv',
|
'./popoverSrv',
|
||||||
'./backendSrv',
|
'./backendSrv',
|
||||||
],
|
],
|
||||||
|
28
src/app/services/analytics.js
Normal file
28
src/app/services/analytics.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -59,5 +59,19 @@
|
|||||||
require(['app'], function (app) {
|
require(['app'], function (app) {
|
||||||
app.boot();
|
app.boot();
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</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>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user