Amplitude-ReactNative icon indicating copy to clipboard operation
Amplitude-ReactNative copied to clipboard

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

Open imanuelvic opened this issue 2 years ago • 3 comments

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

imanuelvic avatar Nov 15 '22 04:11 imanuelvic

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.

yuhao900914 avatar Nov 18 '22 18:11 yuhao900914

Ahh, I see, thank youu @yuhao900914

I just found out there is another link

imanuelvic avatar Nov 19 '22 02:11 imanuelvic

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

imanuelvic avatar Nov 19 '22 17:11 imanuelvic