google / chatbase-node

Quickly integrate your Node.js chatbot with Chatbase Analytics
Apache License 2.0
77 stars 24 forks source link

If setTimestamp is used, throws an error about missing fields #2

Closed beldar closed 7 years ago

beldar commented 7 years ago

Error I'm getting:

Error: One or more required fields were not set on the message, please check the documentation on how to set the following message fields:
api_key, type, user_id, time_stamp, platform, message

Code using it:

.setTimestamp(new Date(event.timestamp).getTime())

which generates a timestamp such as 1503956668941

If setTimestamp is not used, it works fine.

Running this on:

Thanks

cristiancavalli commented 7 years ago

@beldar Have you tried adding toString() to the end of the epoch? We currently only accept stringified epoch's at the API level.

.setTimestamp(new Date(event.timestamp).getTime().toString())

beldar commented 7 years ago

@cristiancavalli yep, that was it. The error message was very misleading tho...

cristiancavalli commented 7 years ago

Hey @beldar thanks for pointing this out -- I'll add some validation logic around this in the client and ping this thread with the commit. Sorry about that..