|
1 | 1 | /****************************************************************************
|
2 |
| - * Copyright 2019-2020, Optimizely, Inc. and contributors * |
| 2 | + * Copyright 2019-2020,2022 Optimizely, Inc. and contributors * |
3 | 3 | * *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); *
|
5 | 5 | * you may not use this file except in compliance with the License. *
|
@@ -243,7 +243,7 @@ func getEventAttributes(projectConfig config.ProjectConfig, attributes map[strin
|
243 | 243 | var eventAttributes = []VisitorAttribute{}
|
244 | 244 |
|
245 | 245 | for key, value := range attributes {
|
246 |
| - if value == nil { |
| 246 | + if !isValidAttribute(value) { |
247 | 247 | continue
|
248 | 248 | }
|
249 | 249 | visitorAttribute := VisitorAttribute{}
|
@@ -291,3 +291,23 @@ func getTagValue(eventTags map[string]interface{}) (float64, error) {
|
291 | 291 |
|
292 | 292 | return 0, errors.New("no event tag found for value")
|
293 | 293 | }
|
| 294 | + |
| 295 | +// check if attribute value is valid |
| 296 | +func isValidAttribute(value interface{}) bool { |
| 297 | + if value == nil { |
| 298 | + return false |
| 299 | + } |
| 300 | + if _, ok := value.(string); ok { |
| 301 | + return true |
| 302 | + } |
| 303 | + if _, ok := value.(float64); ok { |
| 304 | + return true |
| 305 | + } |
| 306 | + if _, ok := value.(int); ok { |
| 307 | + return true |
| 308 | + } |
| 309 | + if _, ok := value.(bool); ok { |
| 310 | + return true |
| 311 | + } |
| 312 | + return false |
| 313 | +} |
0 commit comments