Ability to programmatically disable
In #757, the user wanted to disable Segment in order to respect user preferences. In my use case, we get information about the user at run time that determines if we should or shouldn't track them.
Because the client gets initialized at app load, before user data is fetched, we aren't able to disable immediately. I'd love to be able to do something like:
const segment = useAnalytics();
if (user.type === "non_trackable") {
segment.settings.set({ debug: true/false });
}
A similar behavior seems to exist in Analytics.js (link) so this doesn't seem out of the question. I know it's been flagged as a wontfix but the feature parity would be nice.
BUMP. Currently having our logs flooded by
Flush triggered but queue restoration and settings loading not complete. Flush will be retried.
Would be great to have a simple "enabled: true"
Flush....
same -> what is this about?
@imjared : Starting from v2.21.0, Segment can be disabled by adding segmentClient.enabled.set(true/false).
@sunitaprajapati89 Thanks for the update. Just to confirm, setting this enabled value to true will disable it?
@imjared : enabled as the name says if its true means it is enabled and will track events and false will disable it.