donni106 / matomo-tracker-react-native

Stand alone library for using Matomo tracking in React Native and Expo projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is there any method available from which we can disable the tracking at any time inside the app?

ishaqashrafeyelevel opened this issue · comments

i saw the method setAppOptOut in this package(https://github.com/BonifyByForteil/react-native-matomo) which i think is not available in this package? or may be is there any way to stop tracking within app using some method ?

good question @ishaqashrafeyelevel. in both packages screen views and other events are tracked by action, meaning that you as developer decide, where to put an action for users for tracking. as described in the other package, opting out requires a restart of the app, which also means that some setting can be persisted over app (re)starts to remember user choices. everytime Matomo gets initialised, that setting could to be checked to decide whether to activate or not (opt out).
in this package here you can pass a disabled boolean on initialisation which results in no tracking (opt out) for all distributed actions of an app:

...
// disabled: false, // optional, default value: false. Disables all tracking operations if set to true.
...

(see usage example: https://github.com/donni106/matomo-tracker-react-native#usage)

with having some boolean value persisted in a local storage, that value can be set dynamically on every app start.

one could also check directly on some specific actions in some places/components for a stored value and only disable tracking there instead of disablig entirely.

i hope that this answers your question. feel free to continue this conversation if there is anything else.

@donni106 thanks for the detailed reply. yes you're right need to reload the app every time when the config changed