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

Add event logging upload #127

Merged
merged 24 commits into from
Mar 30, 2020
Merged

Add event logging upload #127

merged 24 commits into from
Mar 30, 2020

Conversation

jkmassel
Copy link
Contributor

@jkmassel jkmassel commented Mar 23, 2020

Adds support for uploading encrypted logs.

Assigned to both @oguzkocer and @shiki, though either (or both) can approve and provide comments as desired.

In the scope of review, I'd love if you're able to comment specifically on whether:

  • All public method documentation is easy to read and understand.
  • The use of preconditions + Implicitly Unwrapped Optionals in EventLoggingUploadManager seems reasonable. Not providing a delegate and a dataSource is a programmer error, so I used these to avoid a bunch of runtime error handling code that should never be called anyway.

To Test:

  • Ensure CI passes
  • Ensure tests pass locally

@jkmassel jkmassel requested a review from shiki March 23, 2020 23:27
@jkmassel jkmassel self-assigned this Mar 23, 2020
jkmassel and others added 2 commits March 23, 2020 17:32
Improve documentation and error handling

.

Remove extras

Revert CrashLogging changes

Don’t make the internal explicit

Tiny fixes

Fix docs
@jkmassel jkmassel force-pushed the add/event-logging-upload branch from 155f5b1 to 7dafc39 Compare March 23, 2020 23:33
@jkmassel jkmassel marked this pull request as ready for review March 23, 2020 23:36
@jkmassel jkmassel requested a review from oguzkocer March 23, 2020 23:37
Copy link
Contributor

@oguzkocer oguzkocer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkmassel My iOS chops are not up to par, so I have a bunch of questions with some of them being possibly stupid. I wanted to get @shiki to review my comments, but he said he was swamped this week. So if anything doesn't make sense to either one of us, we can do a rain dance and conjure him for help.

I skipped reviewing the tests now so I can do them separately once the implementation is all figured out. I hope that's OK with you.

Please let me know if you have any questions.

Automattic-Tracks-iOS/Model/UploadError.swift Outdated Show resolved Hide resolved
Automattic-Tracks-iOS/Model/UploadError.swift Outdated Show resolved Hide resolved
@jkmassel jkmassel force-pushed the add/event-logging-upload branch from 09af253 to 4435485 Compare March 25, 2020 22:29
@jkmassel jkmassel force-pushed the add/event-logging-upload branch from 4435485 to 6b135c5 Compare March 25, 2020 22:30
We can’t guarantee it _won’t_ need to be translated.
Reworks EventLoggingUploadQueue to allow additional customization without subclassing.
@jkmassel jkmassel force-pushed the add/event-logging-upload branch from 1c3b452 to 810b5c9 Compare March 25, 2020 23:00
Simplifies setup for this class by providing a dataSource and delegate at initialization
Reworks the EventLoggingUploadQueue to avoid exposing file parsing bits.

Adds a test to cover the changes
@jkmassel jkmassel requested a review from oguzkocer March 26, 2020 15:19
Copy link
Member

@shiki shiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Sorry for the delay on this. I was able to do a quick look. @oguzkocer had some really great feedback that helped improve the code. So, I just have some tiny suggestions and comments.

It'd also be great if we can add comments to the public symbols like EventLoggingDataSource and EventLoggingDelegate. Comments like how they all connect together or how they should be used would be great. I suppose this could be in future iterations.

@jkmassel
Copy link
Contributor Author

It'd also be great if we can add comments to the public symbols like EventLoggingDataSource and EventLoggingDelegate. Comments like how they all connect together or how they should be used would be great. I suppose this could be in future iterations.

I agree – I'll do this as part of the next PR – the instructions on how to use them make more sense in the context of the wrapper class for this functionality, so I think it'd be hard to review here.

Copy link
Member

@shiki shiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. I'm letting @oguzkocer have the final say since he's the lead reviewer. 🙂

Copy link
Contributor

@oguzkocer oguzkocer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkmassel The implementation part of this PR turned out really well, thanks for taking the time to polish things up!

I left some non-blocking comments for the tests with some examples of how I like to write these type of tests hoping that you find it useful. Feel free to cherry pick them, implement them yourself, merge add/event-logging-upload-pr-suggestions branch which contains all 3 commits or completely ignore them and merge this PR as is. :)

typealias LogFileCallback = (LogFile) -> ()
typealias ErrorWithLogFileCallback = (Error, LogFile) -> ()

enum MockError: Error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use a more specific name for the file? Since I can't comment on the file itself, I am adding it here.

case generic
}

class MockEventLoggingDataSource: EventLoggingDataSource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way this class is written is totally fine for tests, but here is how I would have written it myself: 8723261.

The idea is to promote immutability and control how this class can be used. It has 0 value in this PR in practice, but I thought I'd take the time to mention this in a couple places in this PR for future reference, only if you find it useful of course.

}
}

class MockEventLoggingDelegate: EventLoggingDelegate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very similar to my last comment, here is how I'd have written this class: c3debf1

import XCTest
@testable import AutomatticTracks

class EventLoggingUploadManagerTests: XCTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my previous PR review I tried to explain my thought process for property usage, but it was hard to do so without examples, so I took the time to create one for this PR: f7d87b2.

Similar to my previous PRs it doesn't have much value in tests, but I hope that it'll at least present a good example of how to work with immutability in tests.

There are a couple other files with very minor possible improvements similar to these, but I am leaving these because it's much of the same thing and mentioning these from here after won't have any example value either.

@jkmassel
Copy link
Contributor Author

@oguzkocer – I like the immutability suggestions for the tests – want to open another PR for those changes, and I can approve that one?

@jkmassel jkmassel merged commit c7bfcc6 into develop Mar 30, 2020
@jkmassel jkmassel deleted the add/event-logging-upload branch March 30, 2020 19:49
@oguzkocer
Copy link
Contributor

@jkmassel Looks like develop and that suggestion branch diverged quite a bit, so it creates a big merge conflict. Since the goal of that branch was mostly showcase a different way to go about things, and considering you're leaving for parental leave today :), I think it's fine to just let it die.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants