-
Notifications
You must be signed in to change notification settings - Fork 150
Fix data parameter always undefined on callback for track method #231
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to only add the callback to that flush call and not the other two?
@danieljackins I didn't need to change anywhere else since the place I added solved my problem. Feel free to add in the other places. |
@danieljackins just added the callback parameter to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind make that little change? Just so we're consistent on all three callback
return | ||
} | ||
|
||
if (this.queue.length >= this.flushAt) { | ||
this.flush() | ||
this.flush(callback) | ||
} | ||
|
||
if (this.flushInterval && !this.timer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also another one here:
Line 217 in d2c565d
this.timer = setTimeout(this.flush.bind(this), this.flushInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, @pbassut
just applied the suggestion!
return | ||
} | ||
|
||
if (this.queue.length >= this.flushAt) { | ||
this.flush() | ||
this.flush(callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird bug, may not cause issues, but this actually causes the callback to be called twice now as its the exact same callback pulled from the item when flushed.
https://github.com/segmentio/analytics-node/blob/master/index.js#L247-L259
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc - @pbassut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the callback is running twice for me as well. Is there a plan to fix that? Or should I log a new issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a fix ASAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. Was the fix for this released with v5.1.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pooyaj It's fixed locally. I'm writing some tests and I'll create a PR for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BrandonNoad Can you give me a minimal working example that illustrates the issue?
For issue #1
: seems unlikely given they're only called when the request to segment servers actually finishes(successfully or not).
As for issue #2
: I'll have to see some code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BrandonNoad Please open a new issue for it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pbassut Yes, I can open a new issue with some code to reproduce the behaviour.
For issue #1: seems unlikely given they're only called when the request to segment servers actually finishes(successfully or not).
I may have been incorrect in saying "too early". That was just an assumption based on the fact that the callback is being called twice and in the first call, batch
is undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New issue is here: #300
Fixes: #230