Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2074)

Unified Diff: appengine/gaemiddleware/settings.go

Issue 2248893002: Settings page for analytics ID (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: y Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/gaemiddleware/settings.go
diff --git a/appengine/gaemiddleware/settings.go b/appengine/gaemiddleware/settings.go
index 349e724d8fb57aa038644ba4785348051ae4ba33..0efa118fe6409451917dada9ab32463d26ba989b 100644
--- a/appengine/gaemiddleware/settings.go
+++ b/appengine/gaemiddleware/settings.go
@@ -32,6 +32,10 @@ type gaeSettings struct {
// DisableDSCache is true to disable dscache (the memcache layer on top of
// the datastore).
DisableDSCache settings.YesOrNo `json:"disable_dscache"`
+
+ // AnalyticsID is a Google Analytics ID an admin can set to enable Analytics.
+ // The app must support analytics for this to work.
+ AnalyticsID string `json:"analytics_id"`
Vadim Sh. 2016/08/26 21:55:05 I'm confused, why do you have it in two places? Le
hinoka 2016/08/26 23:11:35 This was a mistake (well, vestige), deleted.
}
// fetchCachedSettings fetches gaeSettings from the settings store or panics.
@@ -54,6 +58,7 @@ func fetchCachedSettings(c context.Context) gaeSettings {
return gaeSettings{
LoggingLevel: logging.Debug,
DisableDSCache: false,
+ AnalyticsID: "",
}
default:
panic(fmt.Errorf("could not fetch GAE settings - %s", err))
@@ -100,6 +105,14 @@ dscache documentation</a> for more information. Toggling this on and off has
consequences: <b>memcache is completely flushed</b>. Do not toy with this
setting.`,
}),
+ {
+ ID: "AnalyticsID",
+ Title: "Google Analytics Trakcing ID",
+ Type: settings.UIFieldText,
+ Help: `Tracking ID used for Google Analytics. Filling this in does not
+by itself add analytics to the app, it must be embedded in the HTML templates
+by calling <TODO: WHAT?>`,
+ },
}, nil
}
@@ -112,6 +125,7 @@ func (settingsUIPage) ReadSettings(c context.Context) (map[string]string, error)
return map[string]string{
"LoggingLevel": s.LoggingLevel.String(),
"DisableDSCache": s.DisableDSCache.String(),
+ "AnalyticsID": s.AnalyticsID,
}, nil
}
@@ -123,6 +137,7 @@ func (settingsUIPage) WriteSettings(c context.Context, values map[string]string,
if err := modified.DisableDSCache.Set(values["DisableDSCache"]); err != nil {
return err
}
+ modified.AnalyticsID = values["AnalyticsID"]
// When switching dscache back on, wipe memcache.
existing := gaeSettings{}

Powered by Google App Engine
This is Rietveld 408576698