Web application / static site hosting with built-in support for simple analytics via Prometheus and Grafana.
Go to file
Mya Pitzeruse 02d115f682
feat(session): support session tracking
This change refactors a handful of components to make them reusable
across pageview and session tracking endpoints.

Resolves https://github.com/mjpitz/pages/issues/2
2022-06-08 10:55:21 -05:00
cmd/pages feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
internal feat(session): support session tracking 2022-06-08 10:55:21 -05:00
legal feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
scripts feat(session): support session tracking 2022-06-08 10:55:21 -05:00
.gitignore feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
.goreleaser.yaml feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
AUTHORS feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
go.mod feat(session): support session tracking 2022-06-08 10:55:21 -05:00
go.sum feat(session): support session tracking 2022-06-08 10:55:21 -05:00
LICENSE feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
Makefile feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
package.json feat: minimal proof of concept 2022-06-03 17:54:25 -05:00
README.md feat(session): support session tracking 2022-06-08 10:55:21 -05:00

pages

pages provides web application / static site hosting with built-in support for simple analytics via Prometheus and Grafana.

Motivation

As I work to reduce the number of Google services from my life, I found myself wanting a simpler alternative to my current hosting solution. Right now, my hosting is provided by GitHub pages and my analytics is provided by Google (as one did in th 2010s). But as we start to enforce more privacy rights through systems like GDPR, I find myself wanting a simpler solution that doesn't require cookie disclosures.

Quickstart with Docker

The easiest way to get started is with Docker. Your web content will be exposed on port 8080 while metrics will be available on 8081.

docker run --rm -it \
  -e PAGES_GIT_URL=<your repo> \
  -e PAGES_GIT_BRANCH=gh-pages \
  -p 8080:8080 \
  -p 8081:8081 \
  img.pitz.tech/mya/pages

Syncing the git repository

You can instruct the server to reload the Git branch by curling this /_admin/sync endpoint.

curl -X POST http://localhost:8080/_admin/sync

This endpoint is exposed publicly so your CI solution can issue the command to cause the servers to update.

Metrics

All metrics are prefixed with the pages namespace. This makes it easy to narrow down to the specific metrics for the system.

pages_page_view_count

The number of page views for a given path and their associated referrer.

# HELP pages_page_view_count the number of times a given page has been viewed and by what referrer
# TYPE pages_page_view_count counter
pages_page_view_count{country="",path="/charts/",referrer="http://localhost:8080/blog/"} 1

pages_page_session_seconds

Histogram of how long users spend on a page.

# HELP pages_page_session_seconds how long someone spent on a given page
# TYPE pages_page_session_seconds histogram
pages_page_session_seconds_bucket{country="",path="/",le="0.005"} 0
pages_page_session_seconds_bucket{country="",path="/",le="0.01"} 0
pages_page_session_seconds_bucket{country="",path="/",le="0.025"} 0
pages_page_session_seconds_bucket{country="",path="/",le="0.05"} 0
pages_page_session_seconds_bucket{country="",path="/",le="0.1"} 0
pages_page_session_seconds_bucket{country="",path="/",le="0.25"} 0
pages_page_session_seconds_bucket{country="",path="/",le="0.5"} 0
pages_page_session_seconds_bucket{country="",path="/",le="1"} 0
pages_page_session_seconds_bucket{country="",path="/",le="2.5"} 1
pages_page_session_seconds_bucket{country="",path="/",le="5"} 1
pages_page_session_seconds_bucket{country="",path="/",le="10"} 1
pages_page_session_seconds_bucket{country="",path="/",le="+Inf"} 1
pages_page_session_seconds_sum{country="",path="/"} 1.855976549
pages_page_session_seconds_count{country="",path="/"} 1