Uh oh!
There was an error while loading. Please reload this page.
Add enable option to disable flushing - #118
Conversation
stephenmathieson
commented
Jul 29, 2017
hulbert
commented
Jul 31, 2017
We're about to add this lib to our systems, and this would be a very nice thing to have. It seems the proposed method of overriding the |
vadimdemedes
commented
Jul 31, 2017
@hulbert is absolutely on point. This is something I'd want too. Recommending overriding Alternatively we could look at newClient('write key',{env: 'production'})Even though it's good, I still prefer having |
vadimdemedes
commented
Oct 13, 2017
@stephenmathieson what do you think? |
stephenmathieson
commented
Oct 13, 2017
While this does seem ideal in many cases, it would break our analytics in our non-prod environments. For example, on .build, we set
I'm 👎 here. Setting
Agreed.
Since there is an obvious demand here, I think this can land. If you fix up the conflicts, I'll approve/merge. 😄 |
1a1f6f8 to
b6b7896Comparevadimdemedes
commented
Oct 13, 2017
I agree on your argument against env option, @stephenmathieson. Explicit option is better. PR is fixed up and ready to get merged! |
| this.flushAt = Math.max(options.flushAt, 1) || 20 | ||
| this.flushInterval = options.flushInterval || 10000 | ||
| this.flushed = false | ||
| this.enabled = options.enable === false ? false : true // eslint-disable-line no-unneeded-ternary |
There was a problem hiding this comment.
Strange use of a ternary here (seems the linter agrees with me). Any reason this.enabled = options.enable won't work?
stephenmathieson
left a comment
There was a problem hiding this comment.
One small thing, but this LGTM!
b6b7896 to
82a4cacComparef2prateek
commented
Nov 1, 2017
What if a customer does this: Basically a customer might want to track some events, and then disable the client but still have the expectation of flushing the previously queued events. I'd prefer if the |
stephenmathieson
commented
Nov 1, 2017
@f2prateek we could just make the |
f2prateek
commented
Nov 2, 2017
SGTM! |
stephenmathieson
commented
Nov 2, 2017
@vadimdemedes think you could make the Object.defineProperty(this,'enabled',{configurable: false,writable: false,value: enabled}) |
f2prateek
commented
Nov 23, 2017
Closing this for now, feel free to re-open once the PR is updated - otherwise the libraries team will tackle it soon. Tracking here https://segment.atlassian.net/browse/LIB-118 |
Fixes#116.
Allows to silently skip sending of messages, which is useful in tests and in development. Example usage: