DataDog / expo-datadog

Datadog SDK for Expo
Apache License 2.0
8 stars 5 forks source link

TypeError: null is not an object (evaluating '_DdSdk.DdSdk.initialize') #22

Closed mexa-team closed 8 months ago

mexa-team commented 10 months ago

Describe what happened Developing an expo go based application. I'm integrating the datadog RUM into the app. After following this documentation, and following the example repository. While testing my application on startup, I see the following Unhandled Promise Rejection error:

Error details ``` WARN Possible Unhandled Promise Rejection (id: 0): TypeError: null is not an object (evaluating '_DdSdk.DdSdk.initialize') http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:215619:25 generatorResume@[native code] asyncGeneratorStep@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25366:26 _next@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25388:29 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25395:14 tryCallTwo@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30816:9 doResolve@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30947:25 Promise@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30835:14 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25384:25 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:215636:25 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:215485:56 generatorResume@[native code] asyncGeneratorStep@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25366:26 _next@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25388:29 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25395:14 tryCallTwo@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30816:9 doResolve@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30947:25 Promise@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30835:14 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25384:25 _initializeFromDatadogProvider@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:215506:55 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:218973:78 generatorResume@[native code] asyncGeneratorStep@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25366:26 _next@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25388:29 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25395:14 tryCallTwo@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30816:9 doResolve@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30947:25 Promise@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30835:14 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25384:25 initializeDatadog@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:218985:24 DatadogProvider@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:219000:26 renderWithHooks@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:10134:33 mountIndeterminateComponent@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:13045:34 beginWork$1@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:18268:29 performUnitOfWork@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:17677:29 workLoopSync@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:17615:28 renderRootSync@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:17593:25 performSyncWorkOnRoot@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:17337:40 performSyncWorkOnRoot@[native code] flushSyncCallbacks@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:7018:36 flushSyncCallbacksOnlyInLegacyMode@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:6999:29 scheduleUpdateOnFiber@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:16921:47 dispatchSetState@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:11089:43 dispatchSetState@[native code] http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:120212:25 generatorResume@[native code] asyncGeneratorStep@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25366:26 _next@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25388:29 tryCallOne@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30808:16 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:30889:27 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:31837:26 _callTimer@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:31737:17 _callReactNativeMicrotasksPass@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:31772:17 callReactNativeMicrotasks@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:31979:44 __callReactNativeMicrotasks@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:24324:46 http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:24103:45 __guard@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:24307:15 flushedQueue@http://192.168.1.12:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:24102:21 flushedQueue@[native code] ```

I console log the config and it was correctly set.

App.js ``` // App.js import { DatadogProvider, DatadogProviderConfiguration, SdkVerbosity } from 'expo-datadog'; const config = new DatadogProviderConfiguration( "x", "prod", "x", true, true, true ); config.site = 'US1'; config.nativeCrashReportEnabled = true; config.sessionSamplingRate = 80; config.resourceTracingSamplingRate = 80; config.firstPartyHosts = ['example.com']; config.verbosity = SdkVerbosity.WARN; const App = () => { return ( {console.log("help")}}> ); }; ```

Steps to reproduce the issue: Following documentation on integrating Datadog with expo RN application. https://docs.datadoghq.com/fr/real_user_monitoring/error_tracking/expo/

Describe what you expected: See RUM sessions on the dashboard for my Expo Go RN application.

Additional context

source ```json { "expo": { "scheme": "mexa", "slug": "mexaminae", "platforms": [ "android", "ios", "web" ], "plugins": [ [ "expo-datadog", { "errorTracking": { "iosDsyms": false, "iosSourcemaps": false } } ] ], ... "updates": { "fallbackToCacheTimeout": 0 }, "assetBundlePatterns": [ "**/*" ], "android": { "versionCode": 50, "package": "com.mexateam.mexaminae" }, "ios": { "buildNumber": "0.5.0", "supportsTablet": true }, "extra": { "eas": { "projectId": "x" } }, "owner": "mexa-team" }, "name": "mexa-app" } ```
source ```json { "name": "mexa-app", "version": "1.0.0", "description": "x", "author": "Mexa Team", "keywords": [ "expo", "react native", "react navigation" ], "main": "node_modules/expo/AppEntry.js", "scripts": { "dev": "npx expo start", "start": "npx expo start", "lint": "eslint ./src", "android": "expo start --android", "ios": "npx expo start --ios", "web": "npx expo start --web", "web-build": "npx expo build:web", "eject": "npx expo eject" }, "dependencies": { "@datadog/mobile-react-native": "^2.0.1", "@datadog/mobile-react-navigation": "^2.0.1", "@expo/vector-icons": "^13.0.0", "@expo/webpack-config": "^0.17.2", "@react-native-async-storage/async-storage": "~1.17.3", "@react-native-community/datetimepicker": "6.5.2", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/slider": "4.2.4", "@react-navigation/bottom-tabs": "^6.3.1", "@react-navigation/native": "^6.0.10", "@react-navigation/native-stack": "^6.6.2", "@reduxjs/toolkit": "^1.8.6", "axios": "^1.1.2", "babel-plugin-transform-inline-environment-variables": "^0.4.4", "expo": "^47.0.0", "expo-asset": "~8.7.0", "expo-av": "~13.0.3", "expo-blur": "~12.0.1", "expo-datadog": "^47.0.0", "expo-dev-client": "~2.0.1", "expo-font": "~11.0.1", "expo-linear-gradient": "~12.0.1", "expo-sharing": "~11.0.1", "expo-splash-screen": "~0.17.5", "expo-updates": "~0.15.6", "fs": "^0.0.1-security", "install": "^0.13.0", "prop-types": "^15.7.2", "react": "18.1.0", "react-dom": "18.1.0", "react-native": "0.70.8", "react-native-dropdown-picker": "^5.4.4", "react-native-gesture-handler": "~2.8.0", "react-native-hide-onkeyboard": "^0.1.6", "react-native-indicators": "^0.17.0", "react-native-multiple-select": "^0.5.11", "react-native-reanimated": "~2.12.0", "react-native-safe-area-context": "4.4.1", "react-native-screens": "~3.18.0", "react-native-searchable-dropdown": "^1.1.3", "react-native-svg": "13.4.0", "react-native-uuid": "^2.0.1", "react-native-web": "~0.18.7", "react-native-webview": "11.23.1", "react-query": "^3.39.2", "react-redux": "^8.0.4", "redux-persist": "^6.0.0", "yarn": "^1.22.18" }, "devDependencies": { "@babel/core": "^7.19.3", "@babel/preset-typescript": "^7.16.5", "@datadog/datadog-ci": "^2.27.0", "@types/react": "~18.0.24", "@types/react-native": "~0.70.6", "babel-eslint": "^10.1.0", "babel-preset-expo": "~9.2.1", "eslint": "7.32.0", "eslint-config-airbnb": "^18.2.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.25.2", "eslint-plugin-import-helpers": "^1.1.0", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.26.1", "eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-native": "^3.11.0", "prettier": "^2.4.1", "typescript": "^4.6.3" }, "prettier": { "singleQuote": true, "trailingComma": "none" }, "eslintIgnore": [ "babel.config.js" ], "private": true } ```
louiszawadzki commented 10 months ago

Hi @mexa-team, thanks for reaching out!

We have a dedicated section in our documentation on how to use Datadog with Expo Go. We recommend switching to Expo Dev Client or using a "mock" in development to prevent the error from happening.

When your application runs inside of Expo Go, we are not able to add any custom native code that is not part of the Expo Go application. Because the RUM React Native SDK relies on some custom native code to run, you cannot use Datadog in a development Expo Go app. This explains the error you're encountering.

Let me know if that answers your question, feel free to ask me to clarify any point :)

mexa-team commented 8 months ago

Hi ! I forgot to respond to your answer. Thanks a lot for the explanation. I understand my misunderstanding now and solve it.