chore: add requestInfo and IP to TrackAction

This commit is contained in:
JesusPerez 2022-03-24 12:57:54 +00:00
parent 08c07fb009
commit a4824ab93d
2 changed files with 22 additions and 0 deletions

13
logs.go
View File

@ -121,4 +121,17 @@ func logRequest(c *gin.Context, rtenv *RouteEnv, run string, route string, info
"tkn": tkn,
}).Info(infoReq)
}
}
func requestInfo(c *gin.Context, rtenv *RouteEnv, run string, route string, tkn string) LogInfo {
accept_langs := strings.Split(c.Request.Header.Get("Accept-Language"),";")
langs := strings.Split(accept_langs[0], ",")
ip, _ := getIP(c.Request)
return LogInfo{
Run: run,
Route: route,
Lang: fmt.Sprintf("%+v",langs),
Agent: fmt.Sprintf("%+v",c.Request.UserAgent()),
Ip: ip,
Tkn: tkn,
}
}

View File

@ -82,6 +82,14 @@ type ConfigPostData struct {
Val string `yaml:"val" json:"val"`
Config cfg.Config `yaml:"config" json:"config"`
}
type LogInfo struct {
Run string `yaml:"run" json:"run"`
Route string `yaml:"route" json:"route"`
Lang string `yaml:"lang" json:"lang"`
Agent string `yaml:"agent" json:"agent"`
Ip string `yaml:"ip" json:"ip"`
Tkn string `yaml:"tkn" json:"tkn"`
}
type TrackAction struct {
When string `yaml:"when" json:"when"`
Where string `yaml:"where" json:"where"`
@ -89,6 +97,7 @@ type TrackAction struct {
Context string `yaml:"context" json:"context"`
Data string `yaml:"data" json:"data"`
Auth string `yaml:"auth" json:"auth"`
Ip string `yaml:"ip" json:"ip"`
}
type PostTrackAction struct {
When string `yaml:"when" json:"when"`