This repository was archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
Fix data parameter always undefined on callback for track method #231
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d871c38
fix data parameter always undefined on callback for track method
b3d2c18
Add missing callback function to a remaining flush call
a64b2c9
Add callback to flush binding
albertininm 85aba9f
Merge branch 'master' into fix-data-callback
nd4p90x b7f7b02
Merge branch 'master' into fix-data-callback
pooyaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -213,16 +213,16 @@ class Analytics { | |||
|
|
||||
| if (!this.flushed) { | ||||
| this.flushed = true | ||||
| this.flush() | ||||
| this.flush(callback) | ||||
| return | ||||
| } | ||||
|
|
||||
| if (this.queue.length >= this.flushAt) { | ||||
| this.flush() | ||||
| this.flush(callback) | ||||
| } | ||||
|
|
||||
| if (this.flushInterval && !this.timer) { | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's also another one here: Line 217 in d2c565d
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, @pbassut |
||||
| this.timer = setTimeout(this.flush.bind(this), this.flushInterval) | ||||
| this.timer = setTimeout(this.flush.bind(this, callback), this.flushInterval) | ||||
| } | ||||
| } | ||||
|
|
||||
|
|
||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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,
batchisundefined.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