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

implemented URLSessionDispatcher #122

Merged
merged 9 commits into from
Mar 12, 2017
Merged

implemented URLSessionDispatcher #122

merged 9 commits into from
Mar 12, 2017

Conversation

brototyp
Copy link
Member

Alright. This is the first version of the URLSessionDispatcher. I think it is ready now and maybe needs some cleanup.

@brototyp brototyp added the swift label Jan 30, 2017
@brototyp brototyp added this to the Swift 3 Rewrite milestone Jan 30, 2017
@brototyp
Copy link
Member Author

Cleanup ist done. I also adapted some of the Example Application. The siteId and Piwik baseURL must be configured in the configuration view first. I just submitted the first view events.

//
// Created by Cornelius Horstmann on 25.02.17.
// Copyright © 2017 Mattias Levin. All rights reserved.
//
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we said to remove those comments?!

Copy link
Member Author

@brototyp brototyp Mar 4, 2017

Choose a reason for hiding this comment

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

That is true.

  • Remove the comments in the header

if (buttonIndex == 0) {
[PiwikTracker sharedInstance].optOut = YES;
} else {
[PiwikTracker sharedInstance].optOut = NO;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have/need tickets/issues for those things that are currently not supported bei the swift version of piwik?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have just written a ticket #124

spec.version = "3.3.0"
spec.summary = "A Piwik tracker written in Objective-C for iOS and OSX apps."
spec.version = "4.0.0-alpha1"
spec.summary = "A Piwik tracker written in Swift for iOS and OSX apps."
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about watchOS and tvOS? Should piwik support those, too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would say we start with iOS and add macOS and tvOS later. I don't think it will be a huge issue though.

}
set {
userDefaults.setValue(newValue, forKey: PiwikUserDefaults.Key.visitorID)
userDefaults.synchronize()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need this synchronize?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. Otherwise we might lose the values we just set. I think we should not risk using the values in case of an early exit (especially an app crash). What do you think @thorstenstark ?


// shared instance
extension Tracker {
public static var sharedInstance: Tracker? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The Swift way for naming shared instances is usually shared, isn't it?

Copy link
Member Author

@brototyp brototyp Mar 4, 2017

Choose a reason for hiding this comment

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

Great comment?

  • change the shared instance property to shared instead of sharedInstance

}

extension Tracker {
public func track(view: [String]) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As this could be multiple views, I would call it track(views: [String]).

Copy link
Member Author

@brototyp brototyp Mar 4, 2017

Choose a reason for hiding this comment

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

I actually is not tracking multiple views. A view can be described by a path/categories. For example videos/cats/15.

Your question definitely shows an issue. All public methods, especially the Tracker, should be documented.

  • Document public Tracker methods.

let task = session.dataTask(with: request) { data, response, error in
// should we check the response?
// let dataString = String(data: data!, encoding: String.Encoding.utf8)
if error == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the response perhaps tell us something we should know/handle?

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I know, the result is only interesting when debugging the sdk. The information it returns possibly helps finding sdk-issues.

What do you think about having a debug property in the Tracker itself which is false per default? If it is set, we parse the data and will print it to the console.

public class func configureSharedInstance(withSiteID siteID: String, baseURL: URL) {
let queue = MemoryQueue()
let dispatcher = URLSessionDispatcher(baseURL: baseURL)
self._sharedInstance = Tracker.init(siteId: siteID, queue: queue, dispatcher: dispatcher)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Somehow this feels kind of strange setting the _sharedInstance in a class function... But I don't have a better solution for now.

@brototyp brototyp merged commit 5a430a0 into matomo-org:swift3 Mar 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants