Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Tracker already initialized warnings in dev mode #30

Open
aeirola opened this issue Nov 9, 2020 · 1 comment
Open

Tracker already initialized warnings in dev mode #30

aeirola opened this issue Nov 9, 2020 · 1 comment

Comments

@aeirola
Copy link
Contributor

aeirola commented Nov 9, 2020

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 (PiwikPRO/sdk-demo-ios#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.

@aeirola
Copy link
Contributor Author

aeirola commented Nov 25, 2020

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);
    });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant