Skip to content

Commit

Permalink
Release 2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
luoziyin committed Dec 9, 2021
1 parent ba597f1 commit 62f6984
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion sensorsanalytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
ITEM_SET = "item_set"
ITEM_DELETE = "item_delete"

SDK_VERSION = "2.0.4"
SDK_VERSION = "2.0.5"
LIB_NAME = "Golang"

MAX_ID_LEN = 255
Expand Down
16 changes: 8 additions & 8 deletions structs/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

const (
KEY_MAX = 256
KEY_MAX = 100
VALUE_MAX = 8192

NAME_PATTERN_BAD = "^(^distinct_id$|^original_id$|^time$|^properties$|^id$|^first_id$|^second_id$|^users$|^events$|^event$|^user_id$|^date$|^datetime$)$"
Expand Down Expand Up @@ -64,15 +64,15 @@ func (e *EventData) NormalizeData() error {
if e.Event != "" {
isMatch := checkPattern([]byte(e.Event))
if !isMatch {
return errors.New("event name must be a valid variable name.")
return errors.New("event name = " + e.Event + " is invalid, event name must be a valid variable name.")
}
}

//check project
if e.Project != "" {
isMatch := checkPattern([]byte(e.Project))
if !isMatch {
return errors.New("project name must be a valid variable name.")
return errors.New("project = " + e.Project + " is invalid, project name must be a valid variable name.")
}
}

Expand All @@ -81,15 +81,15 @@ func (e *EventData) NormalizeData() error {
for k, v := range e.Properties {
//check key
if len(k) > KEY_MAX {
return errors.New("the max length of property key is 256")
return errors.New("the max length of property key is 100," + "key = " + k)
}

if len(k) == 0 {
return errors.New("The key is empty or null.")
return errors.New("The key is empty or null," + "key = " + k + ", value = " + v.(string))
}
isMatch := checkPattern([]byte(k))
if !isMatch {
return errors.New("property key must be a valid variable name.")
return errors.New("property key must be a valid variable name," + "key = " + k)
}

//check value
Expand All @@ -99,14 +99,14 @@ func (e *EventData) NormalizeData() error {
case float64:
case string:
if len(v.(string)) > VALUE_MAX {
return errors.New("the max length of property key is 8192")
return errors.New("the max length of property value is 8192," + "value = " + v.(string))
}
case []string: //value in properties list MUST be string
case time.Time: //only support time.Time
e.Properties[k] = v.(time.Time).Format("2006-01-02 15:04:05.999")

default:
return errors.New("property value must be a string/int/float64/bool/time.Time/[]string")
return errors.New("property value must be a string/int/float64/bool/time.Time/[]string," + "key = " + k)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions structs/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (item *Item) NormalizeItem() error {
for k, v := range item.Properties {
//check key
if len(k) > KEY_MAX {
return errors.New("the max length of property key is 256")
return errors.New("the max length of property key is 100," + "key = " + k)
}
isMatch := checkPattern([]byte(k))
if !isMatch {
Expand All @@ -79,14 +79,14 @@ func (item *Item) NormalizeItem() error {
case float64:
case string:
if len(v.(string)) > VALUE_MAX {
return errors.New("the max length of property key is 8192")
return errors.New("the max length of property value is 8192," + "value = " + v.(string))
}
case []string: //value in properties list MUST be string
case time.Time: //only support time.Time
item.Properties[k] = v.(time.Time).Format("2006-01-02 15:04:05.999")

default:
return errors.New("property value must be a string/int/float64/bool/time.Time/[]string")
return errors.New("property value must be a string/int/float64/bool/time.Time/[]string," + "key = " + k)
}
}
}
Expand Down

0 comments on commit 62f6984

Please sign in to comment.