mirror of
https://github.com/Kugelschieber/marvinblum.git
synced 2026-01-18 06:40:27 +00:00
Added OS, browser, and system statistics to tracking page.
This commit is contained in:
6
main.go
6
main.go
@@ -157,6 +157,9 @@ func serveTracking() http.HandlerFunc {
|
||||
Pages []pirsch.Stats
|
||||
Languages []pirsch.Stats
|
||||
Referrer []pirsch.Stats
|
||||
Browser []pirsch.Stats
|
||||
OS []pirsch.Stats
|
||||
Platform *pirsch.Stats
|
||||
HourlyVisitorsLabels template.JS
|
||||
HourlyVisitorsDps template.JS
|
||||
HourlyVisitorsTodayLabels template.JS
|
||||
@@ -173,6 +176,9 @@ func serveTracking() http.HandlerFunc {
|
||||
tracking.GetPages(startDate, endDate),
|
||||
tracking.GetLanguages(startDate, endDate),
|
||||
tracking.GetReferrer(startDate, endDate),
|
||||
tracking.GetBrowser(startDate, endDate),
|
||||
tracking.GetOS(startDate, endDate),
|
||||
tracking.GetPlatform(startDate, endDate),
|
||||
hourlyVisitorsLabels,
|
||||
hourlyVisitorsDps,
|
||||
hourlyVisitorsTodayLabels,
|
||||
|
||||
@@ -137,6 +137,73 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Browser</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Browser</th>
|
||||
<th>Visitors</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $data := .Browser}}
|
||||
<tr>
|
||||
<td>{{if $data.Browser.Valid}}{{$data.Browser.String}}{{else}}(unknown){{end}}</td>
|
||||
<td>{{$data.Visitors}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Operating System</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>OS</th>
|
||||
<th>Visitors</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $data := .OS}}
|
||||
<tr>
|
||||
<td>{{if $data.OS.Valid}}{{$data.OS.String}}{{else}}(unknown){{end}}</td>
|
||||
<td>{{$data.Visitors}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Platform</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Platform</th>
|
||||
<th>Absolute</th>
|
||||
<th>Relative</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Desktop</td>
|
||||
<td>{{.Platform.PlatformDesktopVisitors}}</td>
|
||||
<td>{{round (multiply .Platform.PlatformDesktopRelative 100)}} %</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Mobile</td>
|
||||
<td>{{.Platform.PlatformMobileVisitors}}</td>
|
||||
<td>{{round (multiply .Platform.PlatformMobileRelative 100)}} %</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>(unknown)</td>
|
||||
<td>{{.Platform.PlatformUnknownVisitors}}</td>
|
||||
<td>{{round (multiply .Platform.PlatformUnknownRelative 100)}} %</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Page Visits</h2>
|
||||
</section>
|
||||
|
||||
@@ -93,6 +93,39 @@ func GetReferrer(startDate, endDate time.Time) []pirsch.Stats {
|
||||
return referrer
|
||||
}
|
||||
|
||||
func GetOS(startDate, endDate time.Time) []pirsch.Stats {
|
||||
os, err := analyzer.OS(&pirsch.Filter{From: startDate, To: endDate})
|
||||
|
||||
if err != nil {
|
||||
logbuch.Error("Error reading OS statistics", logbuch.Fields{"err": err})
|
||||
return nil
|
||||
}
|
||||
|
||||
return os
|
||||
}
|
||||
|
||||
func GetBrowser(startDate, endDate time.Time) []pirsch.Stats {
|
||||
browser, err := analyzer.Browser(&pirsch.Filter{From: startDate, To: endDate})
|
||||
|
||||
if err != nil {
|
||||
logbuch.Error("Error reading browser statistics", logbuch.Fields{"err": err})
|
||||
return nil
|
||||
}
|
||||
|
||||
return browser
|
||||
}
|
||||
|
||||
func GetPlatform(startDate, endDate time.Time) *pirsch.Stats {
|
||||
platform, err := analyzer.Platform(&pirsch.Filter{From: startDate, To: endDate})
|
||||
|
||||
if err != nil {
|
||||
logbuch.Error("Error reading platform statistics", logbuch.Fields{"err": err})
|
||||
return nil
|
||||
}
|
||||
|
||||
return platform
|
||||
}
|
||||
|
||||
func GetHourlyVisitors(startDate, endDate time.Time) (template.JS, template.JS) {
|
||||
visitors, err := analyzer.HourlyVisitors(&pirsch.Filter{From: startDate, To: endDate})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user