@@ -564,7 +564,7 @@ def validate_factory_instantiation(sdk_key):
564564 return True
565565
566566
567- def valid_properties (properties ):
567+ def valid_properties (properties , source ):
568568 """
569569 Check if properties is a valid dict and returns the properties
570570 that will be sent to the track method, avoiding unexpected types.
@@ -580,7 +580,7 @@ def valid_properties(properties):
580580 return True , None , size
581581
582582 if not isinstance (properties , dict ):
583- _LOGGER .error ('track : properties must be of type dictionary.' )
583+ _LOGGER .error ('%s : properties must be of type dictionary.' , source )
584584 return False , None , 0
585585
586586 valid_properties = dict ()
@@ -595,9 +595,8 @@ def valid_properties(properties):
595595 if element is None :
596596 continue
597597
598- if not isinstance (element , str ) and not isinstance (element , Number ) \
599- and not isinstance (element , bool ):
600- _LOGGER .warning ('Property %s is of invalid type. Setting value to None' , element )
598+ if not _check_element_type (element ):
599+ _LOGGER .warning ('%s: Property %s is of invalid type. Setting value to None' , source , element )
601600 element = None
602601
603602 valid_properties [property ] = element
@@ -607,16 +606,22 @@ def valid_properties(properties):
607606
608607 if size > MAX_PROPERTIES_LENGTH_BYTES :
609608 _LOGGER .error (
610- 'The maximum size allowed for the properties is 32768 bytes. ' +
611- 'Current one is ' + str (size ) + ' bytes. Event not queued'
612- )
609+ '%s: The maximum size allowed for the properties is 32768 bytes. ' +
610+ 'Current one is ' + str (size ) + ' bytes. Event not queued' , source )
613611 return False , None , size
614612
615613 if len (valid_properties .keys ()) > 300 :
616- _LOGGER .warning ('Event has more than 300 properties. Some of them will be trimmed' +
617- ' when processed' )
614+ _LOGGER .warning ('%s: Event has more than 300 properties. Some of them will be trimmed' +
615+ ' when processed' , source )
618616 return True , valid_properties if len (valid_properties ) else None , size
619617
618+ def _check_element_type (element ):
619+ if not isinstance (element , str ) and not isinstance (element , Number ) \
620+ and not isinstance (element , bool ):
621+ return False
622+
623+ return True
624+
620625def validate_pluggable_adapter (config ):
621626 """
622627 Check if pluggable adapter contains the expected method signature
0 commit comments