diff options
| author | Dmitri Shuralyov <dmitshur@golang.org> | 2019-10-01 15:53:18 -0400 |
|---|---|---|
| committer | Dmitri Shuralyov <dmitshur@golang.org> | 2019-10-02 17:10:47 +0000 |
| commit | 6bb846ce41cdca087b14c8e3560a679691c424b6 (patch) | |
| tree | 71342ee91029da7d2ae71b63de6e0987ebb225f1 | |
| parent | 45121acd746573507cdaaf902958dba082f7c25b (diff) | |
| download | golang-id-tour-6bb846ce41cdca087b14c8e3560a679691c424b6.tar.xz | |
tour: add analytics HTML and deploy instructions
When deployed with App Engine on tour.golang.org,
insert analytics HTML at the beginning of <head>.
Add deploy instructions to the README.
Also update to the App Engine Go 1.12 runtime.
Change-Id: Ib3333290783f34eb00843006cf949308302b342d
Reviewed-on: https://go-review.googlesource.com/c/tour/+/198320
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
| -rw-r--r-- | README.md | 18 | ||||
| -rw-r--r-- | app.yaml | 11 | ||||
| -rw-r--r-- | appengine.go | 2 | ||||
| -rw-r--r-- | local.go | 4 | ||||
| -rwxr-xr-x | template/index.tmpl | 2 | ||||
| -rw-r--r-- | tour.go | 7 |
6 files changed, 39 insertions, 5 deletions
@@ -36,6 +36,24 @@ The main issue tracker for the tour is located at https://github.com/golang/go/issues. Prefix your issue with "tour:" in the subject line, so it is easy to find. +## Deploying + +1. To deploy tour.golang.org, run: + + ``` + GO111MODULE=on gcloud --project=golang-org app deploy --no-promote app.yaml + ``` + + This will create a new version, which can be viewed within the + [golang-org GCP project](https://console.cloud.google.com/appengine/versions?project=golang-org&serviceId=tour). + +2. Check that the deployed version looks OK (click the version link in GCP). + +3. If all is well, click "Migrate Traffic" to move 100% of the tour.golang.org + traffic to the new version. + +4. You're done. + ## License Unless otherwise noted, the go-tour source files are distributed @@ -1,8 +1,17 @@ service: tour -runtime: go111 +runtime: go112 env_variables: GOLANGORG_CHECK_COUNTRY: true + TOUR_ANALYTICS: | + <script async src="https://www.googletagmanager.com/gtag/js?id=UA-11222381-5"></script> + <script> + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag("js", new Date()); + gtag("config", "UA-11222381-5"); + gtag("config", "UA-49880327-6"); + </script> default_expiration: "7d" diff --git a/appengine.go b/appengine.go index 9398160..c6201a3 100644 --- a/appengine.go +++ b/appengine.go @@ -7,6 +7,7 @@ package main import ( "bufio" "bytes" + "html/template" "io" "log" "net/http" @@ -18,6 +19,7 @@ import ( func gaeMain() { prepContent = gaePrepContent socketAddr = gaeSocketAddr + analyticsHTML = template.HTML(os.Getenv("TOUR_ANALYTICS")) if err := initTour(".", "HTTPTransport"); err != nil { log.Fatal(err) @@ -8,6 +8,7 @@ import ( "flag" "fmt" "go/build" + "html/template" "io" "log" "net" @@ -224,3 +225,6 @@ var prepContent = func(r io.Reader) io.Reader { return r } // socketAddr returns the WebSocket handler address. var socketAddr = func() string { return "ws://" + httpAddr + socketPath } + +// analyticsHTML is optional analytics HTML to insert at the beginning of <head>. +var analyticsHTML template.HTML diff --git a/template/index.tmpl b/template/index.tmpl index 01f94b4..837dc77 100755 --- a/template/index.tmpl +++ b/template/index.tmpl @@ -2,7 +2,7 @@ <html lang="en" ng-app="tour"> <head> - <meta charset="utf-8"> +{{.AnalyticsHTML}} <meta charset="utf-8"> <title>A Tour of Go</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> @@ -57,9 +57,10 @@ func initTour(root, transport string) error { buf := new(bytes.Buffer) data := struct { - SocketAddr string - Transport template.JS - }{socketAddr(), template.JS(transport)} + AnalyticsHTML template.HTML + SocketAddr string + Transport template.JS + }{analyticsHTML, socketAddr(), template.JS(transport)} if err := ui.Execute(buf, data); err != nil { return fmt.Errorf("render UI: %v", err) |
