openculinary/infrastructure

Metrics: log referral domains

Opened this issue · 0 comments

Is your feature request related to a problem? Please describe.
The HTTP referer domain name -- only the domain name part, the full URL is not required -- should be recorded by our infrastructure and logged in the [backend] database in the events schema (see openculinary/backend#75).

Describe the solution you'd like
Since we deploy a single-page progressive web application, index.html should be the only file where the HTTP Referer header is relevant and received.

Similarly, index.html should be served using minimal, high-performance and low-cost infrastructure since it's the application's key entrypoint.

Currently, the frontend service that serves content does not support any dynamic per-request logic, and that's by-design (some template in-fill is performed by webpack at container build-time, but beyond that point the content is served statically).

Ideally, referral event recording should be performed in-cluster since that matches the behaviour of search logging.

I think that the most pragmatic and architecturally-consistent approach is to have a minimal passthrough Python flask microservice that relays requests to the frontend service, and as a side-effect places a log event on a referrals queue for a backend-worker to pick up and store.

Describe alternatives you've considered

  • Serving the frontend content from a Python/flask service directly.
  • Adding an analytics tag to the delivered PWA application.

Additional context
N/A