fix: type checking

This commit is contained in:
Kevin Franklin Kim 2024-07-12 08:16:29 +02:00
parent 8ad1c6cee5
commit 56ab1ada09
No known key found for this signature in database
3 changed files with 6 additions and 26 deletions

View File

@ -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(

View File

@ -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
}

View File

@ -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)
}
}