Open aeirola opened 4 years ago
Until we have a better solution at the library level, a simple local workaround for this looks something like this:
piwikPro
.init(config.apiUrl, config.siteId)
.catch(error => {
// Development server refresh will re-initialized the tracker
// Catch re-init errors for nicer devleoper experience
if (__DEV__ && error.message === 'Tracker already initialized') {
return;
}
console.warn('Failed to initialize Piwik tracker', error);
});
When running an app in development mode, the library will likely complain about
Tracker already initialized
errors on app refreshes. This is due to the fact that the iOS native SDK does not support being initialised more than once (https://github.com/PiwikPRO/piwik-pro-sdk-demo-ios/issues/1).The best fix would be for the native SDK to support re-initialisation, but until that happens it would be nice for this library to provide some way of handling the errors in development mode.