Amplitude-ReactNative
Amplitude-ReactNative copied to clipboard
ERROR: Unhandled promise rejection: TypeError: null is not an object (evaluating 'AmplitudeReactNative.setLibraryName')
Hi, please help!
I’ve just upgrade from Expo SDK 43 to 46, and seems like I need to use a custom development client instead of Expo Go, because of expo-analytics-amplitude will be deprecated in SDK 45. and clearly written in expo documents that expo-analytics-amplitude will be Deprecated. So I need to use the official @amplitude/react-native.
So I migrating from expo-analytics-amplitude to @amplitude/react-native migration
I code in my JavaScript project that I follow the instruction in Installation and Quick Start, and point to React Native SDK (Legacy)
This what I code:
import * as React from 'react
import { Amplitude, Identify } from '@amplitude/react-native'
const ampInstance = Amplitude.getInstance()
ampInstance.init(AMPLITUDE_API_KEY)
And unfortunately appears this error!!
[Unhandled promise rejection: TypeError: null is not an object (evaluating 'AmplitudeReactNative.setLibraryName')]
at node_modules@amplitude\react-native\src\index.ts:null in Amplitude#_setLibraryName
at node_modules@amplitude\react-native\src\index.ts:null in Amplitude#constructor
at node_modules@amplitude\react-native\src\index.ts:null in Amplitude.getInstance
at node_modules@babel\runtime\helpers\asyncToGenerator.js:null in asyncGeneratorStep
at node_modules@babel\runtime\helpers\asyncToGenerator.js:null in _next
at node_modules@babel\runtime\helpers\asyncToGenerator.js:null in Promise$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:null in tryCallTwo
at node_modules\react-native\node_modules\promise\setimmediate\core.js:null in doResolve
at node_modules\react-native\node_modules\promise\setimmediate\core.js:null in Promise
at node_modules@babel\runtime\helpers\asyncToGenerator.js:null in
Hi @imanuelvic, thanks for choosing amplitude. This legacy react-native SDK dose does not support expo. Please take a step to https://www.docs.developers.amplitude.com/data/sdks/typescript-react-native/. Thanks.
Ahh, I see, thank youu @yuhao900914
I just found out there is another link
Hiii @yuhao900914, I need your help
I already use https://www.docs.developers.amplitude.com/data/sdks/typescript-react-native/ as well. And It's work in my Expo Project. But... the data provided in the amplitude dashboard is incomplete and wrong Platform.
Here's the dashboard after I use it:
The platform read Web not Android...
And here's before use @amplitude/analytics-react-native
This is the right one, the User Properties is complete, what I need
Here's my code in Auth Middleware (before user login in my project)
initializeAmplitude = async () => {
init(AMPLITUDE_API_KEY, this.props.userAccountInformation.members.id.toString())
setUserId(this.props.userAccountInformation.members.id.toString())
const identifyObj = new Identify()
identifyObj.set('properties', this.props.userAccountInformation.members)
identifyObj.set('platform', Platform.OS)
identify(identifyObj)
track('Auth Middleware')
track('App Version', { version: Application.nativeApplicationVersion })
this.props.navigation.replace('MainNavigator')
return true
}
How to make the data released as complete as before... Thanks