mirror of
https://github.com/foomo/sesamy-go.git
synced 2025-10-16 12:35:43 +00:00
fix: type checking
This commit is contained in:
parent
8ad1c6cee5
commit
56ab1ada09
@ -97,17 +97,7 @@ func (p *Publisher) Publish(topic string, messages ...*message.Message) error {
|
||||
}
|
||||
|
||||
for s, s2 := range msg.Metadata {
|
||||
// if s == "Cookie" {
|
||||
// for _, s3 := range strings.Split(s2, "; ") {
|
||||
// val := strings.Split(s3, "=")
|
||||
// req.AddCookie(&http.Cookie{
|
||||
// Name: val[0],
|
||||
// Value: strings.Join(val[1:], "="),
|
||||
// })
|
||||
// }
|
||||
// } else {
|
||||
req.Header.Set(s, s2)
|
||||
// }
|
||||
}
|
||||
|
||||
l := p.l.With(
|
||||
|
||||
@ -39,19 +39,6 @@ func Encode(payload *Payload) (url.Values, io.Reader, error) {
|
||||
return nil, nil, errors.Wrap(err, "failed to unmarshall payload")
|
||||
}
|
||||
|
||||
// decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||
// Result: &data,
|
||||
// TagName: "gtag",
|
||||
// IgnoreUntaggedFields: true,
|
||||
// Squash: true,
|
||||
// })
|
||||
// if err != nil {
|
||||
// return nil, nil, errors.Wrap(err, "failed to weakly decode query")
|
||||
// }
|
||||
// if err := decoder.Decode(payload); err != nil {
|
||||
// return nil, nil, errors.Wrap(err, "failed to weakly decode query")
|
||||
// }
|
||||
|
||||
for s, a := range remain {
|
||||
data[s] = a
|
||||
}
|
||||
|
||||
@ -65,13 +65,16 @@ func GTag[P any](source mpv2.Payload[P], target any) error {
|
||||
targetEventProperty := map[string]any{}
|
||||
targetEventPropertyNumber := map[string]any{}
|
||||
for k, v := range params {
|
||||
if s, ok := v.(string); ok {
|
||||
if f, err := strconv.ParseFloat(s, 64); err == nil {
|
||||
switch t := v.(type) {
|
||||
case float64:
|
||||
targetEventPropertyNumber[k] = v
|
||||
case string:
|
||||
if f, err := strconv.ParseFloat(t, 64); err == nil {
|
||||
targetEventPropertyNumber[k] = f
|
||||
} else {
|
||||
targetEventProperty[k] = v
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
targetEventProperty[k] = fmt.Sprintf("%s", v)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user