carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1{{define "app_analytics"}}{{template "top" .}}
2{{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}}
3{{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}}
4{{template "appnav" .}}
5{{template "lognav" .}}
6
7<h2 class="visually-hidden">Analytics</h2>
8{{if .AnalyticsErr}}<p class="banner error">{{.AnalyticsErr}}</p>{{end}}
9{{if not .AnalyticsWin.On}}
10<p><strong>Analytics is off for this app</strong> (from the {{.AnalyticsWin.Setting.CountFrom}}).
11When on, the edge counts HTML page views and daily visitors as it serves them: no JavaScript, no cookie,
12no stored IP. A visitor is a salted hash that changes every day. Turn it on for this app or for the whole
13account on the <a href="{{.Base}}/apps/{{.AppName}}/settings">Settings</a> tab.</p>
14{{end}}
15<form method="get" class="small">
16 <label>range
17 <select name="range">
18 <option value="today"{{if eq .AnalyticsRange "today"}} selected{{end}}>today</option>
19 <option value="7d"{{if eq .AnalyticsRange "7d"}} selected{{end}}>7 days</option>
20 <option value="30d"{{if eq .AnalyticsRange "30d"}} selected{{end}}>30 days</option>
21 </select>
22 </label>
23 <button type="submit">Update</button>
24</form>
25{{with .AnalyticsWin}}
26<div class="tablewrap"><table>
27 <tr><th>Page views</th><th>Visitors{{if ne $.AnalyticsRange "today"}} (daily visitors, summed){{end}}</th><th>Bytes served</th><th>Bots excluded</th><th>Dropped</th></tr>
28 <tr><td>{{.Sum.PV}}</td><td>{{.Sum.Visitors}}</td><td>{{.Sum.Bytes}}</td><td>{{.Sum.Bots}}</td><td>{{.Sum.Dropped.Flush}}</td></tr>
29</table></div>
30{{if .ChartBars}}
31<svg viewBox="0 0 480 140" width="100%" role="img" aria-label="Page views">
32 {{range .ChartBars}}<rect x="{{.X}}" y="{{.Y}}" width="{{.W}}" height="{{.H}}" fill="currentColor"><title>{{.Label}}: {{.Value}}</title></rect>{{end}}
33 <text x="0" y="136" class="small">{{if eq $.AnalyticsRange "today"}}per hour, UTC{{else}}per day{{end}}; peak {{.ChartMax}}</text>
34</svg>
35{{end}}
36{{range .Sum.Days}}{{if .Restarted}}<p class="small">{{.Date}}: counts since the last flush may be missing (the edge restarted that day).</p>{{end}}{{end}}
37<h3>Top pages{{if .Sum.PagesApprox}} <span class="small">approximate: more than 500 distinct keys</span>{{end}}</h3>
38{{template "kvtable" .Sum.Pages}}
39<h3>Top referers{{if .Sum.ReferersApprox}} <span class="small">approximate</span>{{end}}</h3>
40{{template "kvtable" .Sum.Referers}}
41<h3>Named events{{if .Sum.EventsApprox}} <span class="small">approximate</span>{{end}}</h3>
42{{template "kvtable" .Sum.Events}}
43<h3>Countries</h3>
44{{with geoCountries .Sum.Countries}}<div class="tablewrap"><table>{{range sortedKV .}}<tr><td>{{geoLabel .Key}}</td><td>{{.Value}}</td></tr>{{end}}</table></div>{{else}}<p class="small">No country data for this period.</p>{{end}}
45{{range geoAttributions .Sum.GeoSources}}<p class="small"><a href="{{.URL}}">{{.Text}}</a></p>{{end}}
46{{end}}
47<p class="small">Times are UTC. The same view from a terminal: <code>carlos analytics --app {{.AppName}} --range {{.AnalyticsRange}}</code>.</p>
48{{template "bottom" .}}{{end}}
49{{define "kvtable"}}{{if .}}<div class="tablewrap"><table>{{range sortedKV .}}<tr><td>{{.Key}}</td><td>{{.Value}}</td></tr>{{end}}</table></div>{{else}}<p class="small">Nothing yet.</p>{{end}}{{end}}
50