-
Notifications
You must be signed in to change notification settings - Fork 150
Conversation
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 |
@hulbert is absolutely on point. This is something I'd want too. Recommending overriding Alternatively we could look at new Client('write key', { env: 'production' }) Even though it's good, I still prefer having |
@stephenmathieson what do you think? |
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
b6b7896
Compare
I agree on your argument against env option, @stephenmathieson. Explicit option is better. PR is fixed up and ready to get merged! |
index.js
Outdated
@@ -54,6 +54,7 @@ class Analytics { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange use of a ternary here (seems the linter agrees with me). Any reason this.enabled = options.enable
won't work?
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.
No idea what happened here 😆
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.
One small thing, but this LGTM!
b6b7896
to
82a4cac
Compare
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 |
@f2prateek we could just make the |
SGTM! |
@vadimdemedes think you could make the Object.defineProperty(this, 'enabled', {
configurable: false,
writable: false,
value: enabled
}) |
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: