Migrating to version 3.0.0
Running two versions of AppMetrica SDK in parallel
You can use two versions of AppMetrica SDK in your app in parallel. This is undesirable. Statistics should be collected normally, but minor deviations are acceptable. In this case, the app size may increase slightly because it will include two SDKs instead of one.
Alert
We strongly advise against running two SDK versions with the same API_KEY
in the app code. This won't cause the app to
crash or fail, but it will lead to inaccurate and unreliable statistics. When migrating to @appmetrica/react-native-analytics
, make sure that the react-native-appmetrica
plugin isn't mentioned in package-lock.json
or yarn.lock
.
Migration guide
This guide contains examples that show the differences between the plugin versions 2.0.0
and 3.0.0
. This section
covers only the methods that lack backward compatibility.
To migrate to the new version, follow these steps:
- Replace the
react-native-appmetrica
dependency with@appmetrica/react-native-analytics
. See an example in the dependency replacement section. - Edit the import statement in your code. The required changes are provide in the dependency importing section.
- In the project code, replace the classes and methods that were simply renamed. The required changes are indicated in the dependency renaming section.
Replacing dependencies
yarn remove react-native-appmetrica && yarn add @appmetrica/react-native-analytics
npm uninstall react-native-appmetrica && npm install @appmetrica/react-native-analytics
Importing dependencies
import AppMetrica from 'react-native-appmetrica';
Replace with:
import AppMetrica from '@appmetrica/react-native-analytics';
Renamings
- The
requestAppMetricaDeviceId()
method was removed. Use therequestStartupParams()
method to get the IDs. - The
setStatisticsSending()
method was renamed tosetDataSendingEnabled()
.