From 5f61cf92eeabc6ba95072f35460e689954d8f2e3 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 1 Dec 2018 10:20:44 -0800 Subject: cmd/site: back out segment experiment, it's not worth it --- cmd/site/html.go | 12 ------------ cmd/site/main.go | 20 -------------------- 2 files changed, 32 deletions(-) (limited to 'cmd') diff --git a/cmd/site/html.go b/cmd/site/html.go index f42b947..ba304c5 100644 --- a/cmd/site/html.go +++ b/cmd/site/html.go @@ -8,7 +8,6 @@ import ( "time" "github.com/Xe/ln" - analytics "gopkg.in/segmentio/analytics-go.v3" ) func logTemplateTime(name string, from time.Time) { @@ -71,15 +70,4 @@ func (s *Site) showPost(w http.ResponseWriter, r *http.Request) { } s.renderTemplatePage("blogpost.html", p).ServeHTTP(w, r) - - if s.segment != nil { - err := s.segment.Enqueue(analytics.Track{ - UserId: Hash("h", r.Header.Get("X-Forwarded-For")), - Event: "Post Viewed", - Properties: analytics.NewProperties().SetURL(r.RequestURI).SetTitle(p.Title), - }) - if err != nil { - ln.Error(r.Context(), err) - } - } } diff --git a/cmd/site/main.go b/cmd/site/main.go index e9b4d21..fa4b9b8 100644 --- a/cmd/site/main.go +++ b/cmd/site/main.go @@ -17,7 +17,6 @@ import ( "github.com/gorilla/feeds" blackfriday "github.com/russross/blackfriday" "github.com/tj/front" - analytics "gopkg.in/segmentio/analytics-go.v3" ) var port = os.Getenv("PORT") @@ -48,27 +47,12 @@ type Site struct { templates map[string]*template.Template tlock sync.RWMutex - - segment analytics.Client } func (s *Site) ServeHTTP(w http.ResponseWriter, r *http.Request) { ln.Log(r.Context(), ln.F{"action": "Site.ServeHTTP", "user_ip_address": r.RemoteAddr, "path": r.RequestURI}) s.mux.ServeHTTP(w, r) - - if s.segment != nil { - if !strings.HasPrefix(r.RequestURI, "/blog/") { - err := s.segment.Enqueue(analytics.Track{ - UserId: Hash("h", r.Header.Get("X-Forwarded-For")), - Event: "Page Viewed", - Properties: analytics.NewProperties().SetURL(r.RequestURI), - }) - if err != nil { - ln.Error(r.Context(), err) - } - } - } } // Build creates a new Site instance or fails. @@ -105,10 +89,6 @@ func Build() (*Site, error) { templates: map[string]*template.Template{}, } - if wk := os.Getenv("SEGMENT_WRITE_KEY"); wk != "" { - s.segment = analytics.New(wk) - } - err := filepath.Walk("./blog/", func(path string, info os.FileInfo, err error) error { if err != nil { return err -- cgit v1.2.3