logging i guess

This commit is contained in:
Cadey Ratio 2018-08-22 03:21:09 +00:00
parent 6b7d6dcc49
commit 66902783a1
2 changed files with 8 additions and 2 deletions

View File

@ -73,10 +73,13 @@ func (s *Site) showPost(w http.ResponseWriter, r *http.Request) {
s.renderTemplatePage("blogpost.html", p).ServeHTTP(w, r) s.renderTemplatePage("blogpost.html", p).ServeHTTP(w, r)
if s.segment != nil { if s.segment != nil {
s.segment.Enqueue(&analytics.Track{ err := s.segment.Enqueue(&analytics.Track{
UserId: Hash(r.RemoteAddr, r.Header.Get("X-Forwarded-For")), UserId: Hash(r.RemoteAddr, r.Header.Get("X-Forwarded-For")),
Event: "Post Viewed", Event: "Post Viewed",
Properties: analytics.NewProperties().SetURL(r.RequestURI).SetTitle(p.Title), Properties: analytics.NewProperties().SetURL(r.RequestURI).SetTitle(p.Title),
}) })
if err != nil {
ln.Error(r.Context(), err)
}
} }
} }

View File

@ -59,11 +59,14 @@ func (s *Site) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if s.segment != nil { if s.segment != nil {
if !strings.HasPrefix(r.RequestURI, "/blog/") { if !strings.HasPrefix(r.RequestURI, "/blog/") {
s.segment.Enqueue(&analytics.Track{ err := s.segment.Enqueue(&analytics.Track{
UserId: Hash(r.RemoteAddr, r.Header.Get("X-Forwarded-For")), UserId: Hash(r.RemoteAddr, r.Header.Get("X-Forwarded-For")),
Event: "Page Viewed", Event: "Page Viewed",
Properties: analytics.NewProperties().SetURL(r.RequestURI), Properties: analytics.NewProperties().SetURL(r.RequestURI),
}) })
if err != nil {
ln.Error(r.Context(), err)
}
} }
} }
} }