Skip to content

Commit

Permalink
Merge pull request #47 from starsep/dnt_gpc_analytics
Browse files Browse the repository at this point in the history
Don't send analytics if user has DNT/GPC enabled
  • Loading branch information
lazamar authored Aug 29, 2024
2 parents d5076f6 + c3bae94 commit 727859d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Data.Time.Calendar (Day, showGregorian)
import Data.Time.Clock (UTCTime(..))
import Data.Time.Clock.POSIX (POSIXTime, posixSecondsToUTCTime)
import Network.HTTP.Types (status200, status404, renderQuery, queryTextToQuery)
import Network.Wai (Application, Request, Response, responseLBS, rawPathInfo, queryString)
import Network.Wai (Application, Request, Response, requestHeaders, responseLBS, rawPathInfo, queryString)
import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
import Text.Blaze.Html5 ((!))
import Text.Blaze (toValue, toMarkup)
Expand Down Expand Up @@ -66,7 +66,10 @@ pageHome database request = do
return $ responseLBS status200 [("Content-Type", "text/html")] $ renderHtml $
H.docTypeHtml do
H.head do
analytics
if lookup "DNT" (requestHeaders request) /= Just "1" &&
lookup "Sec-GPC" (requestHeaders request) /= Just "1"
then analytics
else return ()
H.title "Nix Package Versions"
H.link
! A.rel "shortcut icon"
Expand Down

0 comments on commit 727859d

Please sign in to comment.