forked from cadey/xesite
cmd/site: back out segment experiment, it's not worth it
This commit is contained in:
parent
80f5b1c1d6
commit
5f61cf92ee
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
9
go.mod
9
go.mod
|
@ -1,26 +1,21 @@
|
|||
module github.com/Xe/site
|
||||
|
||||
require (
|
||||
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da // indirect
|
||||
github.com/Xe/gopreload v0.0.0-20170326043426-a00a8beb369c
|
||||
github.com/Xe/jsonfeed v0.0.0-20170520170432-e21591505612
|
||||
github.com/Xe/ln v0.0.0-20170921000907-466e05b2ef3e
|
||||
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/google/gops v0.3.2
|
||||
github.com/gorilla/feeds v1.0.0
|
||||
github.com/jtolds/qod v0.0.0-20170925014538-3abb44dfc7ba // indirect
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/magefile/mage v0.0.0-20171025021237-ab3ca2f6f855 // indirect
|
||||
github.com/pkg/errors v0.8.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/russross/blackfriday v0.0.0-20170806171014-cadec560ec52
|
||||
github.com/segmentio/backo-go v0.0.0-20160424052352-204274ad699c // indirect
|
||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 // indirect
|
||||
github.com/st3fan/jsonfeed v0.0.0-20170519104842-498b2850d26b // indirect
|
||||
github.com/stretchr/testify v1.2.2 // indirect
|
||||
github.com/tj/front v0.0.0-20170212063142-739be213b0a1
|
||||
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/segmentio/analytics-go.v3 v3.0.0-20180814014620-14e03163be03
|
||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 // indirect
|
||||
)
|
||||
|
|
14
go.sum
14
go.sum
|
@ -1,17 +1,15 @@
|
|||
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da/go.mod h1:DgrzXonpdQbfN3uYaGz1EG4Sbhyum/MMIn6Cphlh2bw=
|
||||
github.com/Xe/gopreload v0.0.0-20170326043426-a00a8beb369c h1:lqTJqaoonxgJMvvfl1ukr/3qCEGWC0nQxzPezbJrhHs=
|
||||
github.com/Xe/gopreload v0.0.0-20170326043426-a00a8beb369c/go.mod h1:0aSWHJguPNHo6zlU7A4Ktua1A/VUr5Jdr1QZ2amOkAQ=
|
||||
github.com/Xe/jsonfeed v0.0.0-20170520170432-e21591505612 h1:5cPld6YTMozzm3lK9VCnOErgoFbADM2hZc4KDu0YNKs=
|
||||
github.com/Xe/jsonfeed v0.0.0-20170520170432-e21591505612/go.mod h1:UKXAbYA/G9yE+cPbpfiP7FlT6Kr3N2mbEjQEJ9hT004=
|
||||
github.com/Xe/ln v0.0.0-20170921000907-466e05b2ef3e h1:uMC/C/zBov+PItx2c6Vax4lt37X+2V5X7NWRcXsxuzE=
|
||||
github.com/Xe/ln v0.0.0-20170921000907-466e05b2ef3e/go.mod h1:hDOCtu3XM9SVMB0UHBilUvRbZ0JKMI7IDbvBzwclIb0=
|
||||
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb/go.mod h1:U0vRfAucUOohvdCxt5MWLF+TePIL0xbCkbKIiV8TQCE=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/gops v0.3.2 h1:n9jMkrye8dh3WQ0IxG5dzLRIhQeZDZoGaj0D7T7x7hQ=
|
||||
github.com/google/gops v0.3.2/go.mod h1:pMQgrscwEK/aUSW1IFSaBPbJX82FPHWaSoJw1axQfD0=
|
||||
github.com/gorilla/feeds v1.0.0 h1:EbkEvaYf+PXhYNHS20heBG7Rl2X6Zy8l11ZBWAHkWqE=
|
||||
github.com/gorilla/feeds v1.0.0/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA=
|
||||
github.com/jtolds/qod v0.0.0-20170925014538-3abb44dfc7ba/go.mod h1:CC0XsLGDIrizqHTsUEJh89QHzv2u2mix/O9xl4+LqSw=
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro=
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
|
@ -19,14 +17,12 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/magefile/mage v0.0.0-20171025021237-ab3ca2f6f855/go.mod h1:IUDi13rsHje59lecXokTfGX0QIzO45uVPlXnJYsXepA=
|
||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday v0.0.0-20170806171014-cadec560ec52 h1:xZ0R4UuR0EDx7m0OmvsqZaomfqCeYJ/PyLm94WLhnIM=
|
||||
github.com/russross/blackfriday v0.0.0-20170806171014-cadec560ec52/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/segmentio/backo-go v0.0.0-20160424052352-204274ad699c h1:rsRTAcCR5CeNLkvgBVSjQoDGRRt6kggsE6XYBqCv2KQ=
|
||||
github.com/segmentio/backo-go v0.0.0-20160424052352-204274ad699c/go.mod h1:kJ9mm9YmoWSkk+oQ+5Cj8DEoRCX2JT6As4kEtIIOp1M=
|
||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 h1:/vdW8Cb7EXrkqWGufVMES1OH2sU9gKVb2n9/1y5NMBY=
|
||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/st3fan/jsonfeed v0.0.0-20170519104842-498b2850d26b h1:i9Wk9W2bjrMvUf59rJKX4/lvZXy3L3lcX7g18c8AveU=
|
||||
|
@ -35,11 +31,7 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1
|
|||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/tj/front v0.0.0-20170212063142-739be213b0a1 h1:lA+aPRvltlx2fwv/BnxyYSDQo3pIeqzHgMO5GvK0T9E=
|
||||
github.com/tj/front v0.0.0-20170212063142-739be213b0a1/go.mod h1:deJrtusCTptAW4EUn5vBLpl3dhNqPqUwEjWJz5UNxpQ=
|
||||
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g=
|
||||
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/segmentio/analytics-go.v3 v3.0.0-20180814014620-14e03163be03 h1:VE9ONTFmnLVqBF4kx4jy+IsK8fCQCy7cIff269RITxs=
|
||||
gopkg.in/segmentio/analytics-go.v3 v3.0.0-20180814014620-14e03163be03/go.mod h1:4QqqlTlSSpVlWA9/9nDcPw+FkM2yv1NQoYjUbL9/JAw=
|
||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
|
||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
||||
|
|
Loading…
Reference in New Issue