in src/main/scala/com/gu/contentapi/models/Event.scala [19:36]
def apply(fastlyLog: FastlyLog): Option[Event] = {
val parsedUrl = okhttp3.HttpUrl.parse(hostUrl + fastlyLog.url)
val path = parsedUrl.encodedPath()
val absoluteUrlToFile = hostUrl + path
for {
rawPath <- fastlyLog.url.split("""\?""").headOption //The CAPI client takes care of url encoding
info <- PodcastLookup.getPodcastInfo(hostUrl + rawPath)
} yield Event(
viewId = LongHashFunction.xx_r39().hashChars(absoluteUrlToFile + fastlyLog.time + fastlyLog.ipAddress + fastlyLog.userAgent).toString,
url = absoluteUrlToFile,
ipAddress = fastlyLog.ipAddress,
episodeId = info.episodeId,
podcastId = info.podcastId,
ua = fastlyLog.userAgent,
platform = Option(parsedUrl.queryParameter("platform")))
}