segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
354 stars 182 forks source link

JS Date object not transformed to ISO string #835

Closed servercimen closed 1 year ago

servercimen commented 1 year ago

An event property of type "Date time" is translated to JS with type "Date" by typewriter. However, when this is send to segment backend it's showing up as the following on segment debugger instead of ISO string.

Manually sending an ISO string representation of the date object causes type errors as expected.

Please note that we have a similar setup for our website and sending a Date object works find with segment analytics-react.

"date": {
      "type": "UNIX_timestamp",
      "value": 1684540800000
    },

Steps to reproduce

Expected behavior The date is send to segment backend as an ISO string like the following: "date": "2023-06-02T07:00:00.000Z"

Actual behavior It's recorded as an object with two keys as demonstrated below.

"date": {
      "type": "UNIX_timestamp",
      "value": 1685689200000
    },
zikaari commented 1 year ago

Hi @servercimen I couldn't reproduce the issue, I have a feeling it might have been fixed in one of our direct or indirect dependencies. Can you please retry re-generating the tracking plan through Segment dashboard?

The output looks like this for me, notice how the type is not ["string", null] in my case: Screenshot 2023-06-16 at 12 53 31 PM

zikaari commented 1 year ago

Hi @servercimen please let us know if the issue still persists

servercimen commented 1 year ago

Thanks for checking @zikaari, we have changed our date fields to be just regular strings due to this problem but so I don't have a quick way to check. Next time we're adding date fields I can give it another try.