Description
Context
When attempting to send an event from Segment Analytics in our Flutter app, the event timestamp appears to be set in the future, causing the event to fail in Mixpanel with a 400 Bad Request error. This issue is likely due to a timestamp misalignment within the Flutter package.
Reproduction Steps:
- Send an event from Segment Analytics in the Flutter app.
- Observe that the timestamp is set in the future compared to the sentAt time.
- This discrepancy causes Mixpanel to reject the event, as seen in the error response.
Testing with Event Tester in Segment
Event Example Input
{
"_metadata": {
"bundled": [],
"bundledIds": [],
"unbundled": [
"Mixpanel (Actions)",
"Actions Customerio"
]
},
"anonymousId": "30b68915-5309-417a-9abe-5d8eeb214668",
"channel": "client",
"context": {
"app": {
"build": "229",
"name": "Doshi Learn",
"namespace": "app.doshi.learn",
"version": "1.0.52"
},
"device": {
"manufacturer": "Apple",
"model": "arm64",
"name": "iPhone",
"type": "ios"
},
"instanceId": "772bddad-b136-4472-9ed7-1719be0319c0",
"ip": "49.37.221.254",
"library": {
"name": "analytics-flutter",
"version": "1.0.0"
},
"locale": "en-IN",
"network": {
"cellular": false,
"wifi": true
},
"os": {
"name": "iOS",
"version": "18.0"
},
"screen": {
"height": 874,
"width": 402
},
"timezone": "Asia/Kolkata",
"traits": {
"email": "[email protected]",
"firstName": "Venkatesh",
"lastName": "Test",
"name": "Venkatesh Test"
}
},
"integrations": {},
"messageId": "39c97213-92b2-4750-b79b-a92091d5be45",
"name": "LessonStartRoute",
"originalTimestamp": "2024-10-31T23:20:09.664979",
"projectId": "ps4WJH9SaiEPUk7cpH1j9n",
"properties": {},
"receivedAt": "2024-10-31T17:50:16.188Z",
"sentAt": "2024-10-31T17:50:15.238Z",
"timestamp": "2024-10-31T23:20:10.615Z",
"type": "screen",
"userId": "jnrhh8z57qhGgWO4btIJOTAh6gD3",
"version": 2
}
Error Response from Mixpanel:
{
"body": {
"code": 400,
"error": "some data points in the request failed validation",
"failed_records": [
{
"field": "properties.time",
"index": 0,
"insert_id": "39c97213-92b2-4750-b79b-a92091d5be45",
"message": "'properties.time' is invalid: must not be in the future"
}
],
"num_records_imported": 0,
"status": "Bad Request"
},
"statusCode": 400,
"statusMessage": "Bad Request"
}
Details: In the input, the sentAt field (2024-10-31T17:50:15.238Z) is accurate, but the timestamp field (2024-10-31T23:20:10.615Z) is incorrectly set in the future. Mixpanel requires the event timestamp to be valid and within the current time frame, resulting in this failure.
Suspected Cause: This appears to be due to a potential timezone-related issue in the Segment Analytics Flutter SDK, where the timestamp is not being correctly synchronized with sentAt based on the device timezone.
Expected Outcome: The timestamp should be aligned with the actual event time (sentAt) to prevent Mixpanel from rejecting events due to a future-dated timestamp.