segment-integrations / analytics.js-integration-facebook-pixel

The Facebook Pixel analytics.js integration. https://segment.com/docs/integrations/facebook-pixel
MIT License
8 stars 16 forks source link

Add conversion of ISO-8601 dates to YYYY-MM-DD #33

Closed ccnixon closed 7 years ago

ccnixon commented 7 years ago

This pr addresses an issue with converting iso formatted dates to a date formate FB will accept. Per their docs Facebook stipulates that dates for specific travel related fields can only be passed in the following format:

YYYYMMDD e.g. 20170623
YYYY-MM-DD e.g. 2017-06-23
YYYY-MM-DDThh:mmTZD e.g. 2017-06-23T15:30GMT
YYYY-MM-DDThh:mm:ssTZD e.g. 2017-06-23T15:30:00GMT

Previously, if you were passing us iso formatted dates as the values of those spec'd properties, we were converting them to date objects which was preventing them from being properly parsed by FB.

Now, if we recognize that Facade has parsed a date string into a date object, we are going to return the original (ie non-utc-offset) version of the date, remove the time/utc offset, and send through the date as YYYY-MM-DD.

TODO: add docs explaining how to properly pass times/timezones for these fields.

Jira ticket: https://segment.atlassian.net/browse/EPD-2936