Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format NSDate objects to RFC 3339 compliant strings. #723

Merged
merged 2 commits into from
Oct 20, 2017

Conversation

djfink
Copy link
Contributor

@djfink djfink commented Oct 14, 2017

What does this PR do?

Fixes and issue where dates were not being formatted correctly before being sent to Segment. The correct way to handle RFC 3339 with NSDateFormatter is detailed here: https://developer.apple.com/library/content/qa/qa1480/_index.html. The one small change is to include milliseconds as they were there previously. This will still be RFC 3339 compliant as can be seen here: https://tools.ietf.org/html/rfc3339#section-5.8.

Where should the reviewer start?

N/A

How should this be manually tested?

Sends some date data through the SDK and verify it is being formatted correctly.

Any background context you want to provide?

After talking to Segment support I learned our date traits were not being sent to Redshift because they were not RFC 3339 compliant. The link to the support ticket is here:
https://segment.zendesk.com/hc/requests/87566

What are the relevant tickets?

N/A

Screenshots or screencasts (if UI/UX change)

N/A

Questions:

  • Does the docs need an update? No
  • Are there any security concerns? No
  • Do we need to update engineering / success? No

@segmentio/gateway

@codecov-io
Copy link

codecov-io commented Oct 14, 2017

Codecov Report

Merging #723 into dev will increase coverage by 0.75%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##              dev     #723      +/-   ##
==========================================
+ Coverage   71.27%   72.03%   +0.75%     
==========================================
  Files          39       39              
  Lines        1633     1634       +1     
  Branches      174      174              
==========================================
+ Hits         1164     1177      +13     
+ Misses        351      338      -13     
- Partials      118      119       +1

@f2prateek
Copy link
Contributor

Thanks! Could we add a small test case for iso8601FormattedString as well?

@f2prateek
Copy link
Contributor

@djfink
Copy link
Contributor Author

djfink commented Oct 14, 2017

I'd like to keep in the milliseconds as it looks like the segment backend is using this format for date fields it generates like "receivedAt". I didn't see anyway to do this with NSISO8601DateFormatter. NSISO8601DateFormatWithFractionalSeconds looks promising but it is only available in iOS 11.0+

@f2prateek
Copy link
Contributor

Ok that's fair, it'd be great to get some simple test cases added here and we can get this merged!

@f2prateek
Copy link
Contributor

Awesome, thanks! Just waiting on CI and will merge right after.

@djfink
Copy link
Contributor Author

djfink commented Oct 20, 2017

Sounds good, thanks!

@f2prateek f2prateek merged commit f7af753 into segmentio:dev Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants