How to know whether AnalyticsCollectionEnabled is enabled to not? #5254
-
For GDPR, we need to implement a turn on/off switch to enable/disable logging analytics data. We can easily set it enabled/disabled as follows: // by default true - this need to changed - based on anayticsCollection enabled or not
const [analytics, setAnalytics] = useState(true)
const toggleAnalytics = async () => {
await firebase.analytics().setAnalyticsCollectionEnabled(!analytics)
setAnalytics(!analytics)
}
return (
<Switch
trackColor={{ true: theme.palette.primary }}
style={styles.switch}
onValueChange={toggleAnalytics}
value={analytics}
/>
) However, after adjusting the settings, we need to able to know whether anayticsCollection enabled or not to initialize the state(switch value) next time. How can we do that? couldn't find anything on doc/codebase. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There is no API for that in the corresponding module for firebase-js-sdk (which we pattern off of): https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics#setanalyticscollectionenabled Which implies that you must keep track of it. AsyncStorage is typically how people solve problems like this where they must keep track of state. |
Beta Was this translation helpful? Give feedback.
There is no API for that in the corresponding module for firebase-js-sdk (which we pattern off of): https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics#setanalyticscollectionenabled
Which implies that you must keep track of it. AsyncStorage is typically how people solve problems like this where they must keep track of state.