-
Remove amplitude-js from your package.json
-
Install @amplitude/react-native
-
If targeting iOS, cd into
/ios
and runpod install
-
Replace imports with one of the following:
import { Amplitude } from '@amplitude/react-native'
import { Identify } from '@amplitude/react-native'
import { Amplitude, Identify } from '@amplitude/react-native'
-
The API's between the two libraries are very similar but there are some subtle differences discussed below. You can reference the documentation for detailed API documentation and typing for
@amplitude/react-native
:-
calls to
Amplitude.getInstance().init
only require passing your API key. There is no options object.
- The followingamplitude-js
methods are not supported in@amplitude/react-native
:setDomain
isNewSession
setVersionName
logEventWithTimestamp
logEventWithGroups
-
A significant change is that
@amplitude-react/native
does not export a revenue class. Instead, it is replaced with calls to the following method:Amplitude.getInstance().logRevenue
documentation -
Because there is no support for
logEventWithTimestamp
orlogEventWithGroups
. You can simulate this functionality by providing your own custom timestamp or callingsetGroup
before callinglogEvent
.
-