Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Unhandled promise rejection: TypeError: null is not an object (evaluating 'AmplitudeReactNative.setLibraryName') #152

Open
imanuelvic opened this issue Nov 15, 2022 · 3 comments

Comments

@imanuelvic
Copy link

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
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
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\react-native\node_modules\promise\setimmediate\core.js:null in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:null in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in _allocateCallback$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in _callReactNativeMicrotasksPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in callReactNativeMicrotasks
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __callReactNativeMicrotasks
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in flushedQueue

@yuhao900914
Copy link
Contributor

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.

@imanuelvic
Copy link
Author

Ahh, I see, thank youu @yuhao900914

I just found out there is another link

@imanuelvic
Copy link
Author

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:
image
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
image

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

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

No branches or pull requests

2 participants