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

Fixed a bug, where the tracker would stop automatic dispatching. #169

Merged
merged 1 commit into from
Jul 23, 2017

Conversation

brototyp
Copy link
Member

No description provided.

@minitrue22
Copy link
Contributor

#167

@@ -96,6 +96,7 @@ final public class PiwikTracker: NSObject {
guard events.count > 0 else {
// there are no more events queued, finish dispatching
self.isDispatching = false
self.startDispatchTimer()
Copy link
Contributor

Choose a reason for hiding this comment

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

startDispatchTimer is called from different levels/abstractions in the code.
Eventually it might become hard to make sure all code branches are covered since the call is spread out in the code.

One option would be if dispatchBatch() took a closure that is called when it is done. Then the logic can be confined to the dispatch() method (I think).

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it is possible to cleanup the whole dispatching process. It looks a bit overly complex for what it does. I will try to create a proposal.

@@ -96,6 +96,7 @@ final public class PiwikTracker: NSObject {
guard events.count > 0 else {
// there are no more events queued, finish dispatching
self.isDispatching = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed that isDispatching is not thread safe, depending on what thread the caller calls the dispatch() method. There is a risk that the timer is not started/stopped as it should.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would fix that in a separate PR since the current bug is critical

@@ -105,15 +106,20 @@ final public class PiwikTracker: NSObject {
self.dispatchBatch()
})
}, failure: { shouldContinue in
self.logger.warning("Failed dispatching events with error \(shouldContinue)")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not part of this PR but what is shouldContinue? From the name I would say it's a Bool, but it is logged in the warning as error?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for that. I just renamed it.

@brototyp brototyp force-pushed the bugfix/167-fixed-stalling-dispatching branch from 37890b3 to 332bbe0 Compare July 23, 2017 13:41
@brototyp brototyp merged commit 7416221 into develop Jul 23, 2017
@brototyp brototyp deleted the bugfix/167-fixed-stalling-dispatching branch July 23, 2017 13:56
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.

3 participants