Skip to content

Commit

Permalink
ingest: fill userAgent and locale only for browser ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Jan 31, 2024
1 parent 0cbf1ac commit baed078
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ingest/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ func patchEvent(c *gin.Context, messageId string, event *AnalyticsServerEvent, t
if ingestType == IngestTypeBrowser {
//if ip comes from browser, don't trust it!
ctx["ip"] = ip
}
if _, ok = ctx["userAgent"]; !ok {
ctx["userAgent"] = c.GetHeader("User-Agent")
}
if _, ok = ctx["locale"]; !ok {
ctx["locale"] = strings.TrimSpace(strings.Split(c.GetHeader("Accept-Language"), ",")[0])
if _, ok = ctx["userAgent"]; !ok {
ctx["userAgent"] = c.GetHeader("User-Agent")
}
if _, ok = ctx["locale"]; !ok {
ctx["locale"] = strings.TrimSpace(strings.Split(c.GetHeader("Accept-Language"), ",")[0])
}
}
ev["context"] = ctx
nowIsoDate := time.Now().UTC().Format(timestamp.JsonISO)
Expand Down

0 comments on commit baed078

Please sign in to comment.