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

Cannot "disable" Datadog native modules in Expo Go #223

Closed
holyris opened this issue Jun 23, 2022 · 2 comments · Fixed by #224
Closed

Cannot "disable" Datadog native modules in Expo Go #223

holyris opened this issue Jun 23, 2022 · 2 comments · Fixed by #224
Labels
bug Something isn't working

Comments

@holyris
Copy link

holyris commented Jun 23, 2022

Hello, i'm using expo SDK 44 so I followed this documentation https://docs.datadoghq.com/fr/real_user_monitoring/reactnative/expo/ to disable datadog in dev mode.

The error i get:
Exception in HostObject::set for prop 'DdSdk'

Any clue ?

@holyris holyris added the bug Something isn't working label Jun 23, 2022
@louiszawadzki
Copy link
Contributor

Hi @holyris,

Thank you for reporting this! It looks like this "hack" has not been tested enough, sorry for that.

Here's a version of the mockDatadog.ts file that I've tested more thoroughly, tell me if it works for you. If so I'll update our documentation shortly.

// mockDatadog.ts
import {
  DdLogs,
  DdTrace,
  DdRum,
  DdSdkReactNative,
} from "@datadog/mobile-react-native";

if (__DEV__) {
  const emptyAsyncFunction = () => new Promise<void>((resolve) => resolve());

  DdLogs.debug = emptyAsyncFunction;
  DdLogs.info = emptyAsyncFunction;
  DdLogs.warn = emptyAsyncFunction;
  DdLogs.error = emptyAsyncFunction;

  DdTrace.startSpan = () =>
    new Promise<string>((resolve) => resolve("fakeSpanId"));
  DdTrace.finishSpan = emptyAsyncFunction;
  DdRum.startView = emptyAsyncFunction;
  DdRum.stopView = emptyAsyncFunction;
  DdRum.startAction = emptyAsyncFunction;
  DdRum.stopAction = emptyAsyncFunction;
  DdRum.addAction = emptyAsyncFunction;
  DdRum.startResource = emptyAsyncFunction;
  DdRum.stopResource = emptyAsyncFunction;
  DdRum.addError = emptyAsyncFunction;
  DdRum.addTiming = emptyAsyncFunction;

  DdSdkReactNative.initialize = emptyAsyncFunction;
  DdSdkReactNative.setUser = emptyAsyncFunction;
  DdSdkReactNative.setAttributes = emptyAsyncFunction;
  DdSdkReactNative.setTrackingConsent = emptyAsyncFunction;
}

We also recommend switching to Expo development builds as they enable you to:

  • check your integration with Datadog before shipping your app
  • make update to Datadog's SDK more easily by testing it locally
  • have insights on your debug application as well

If you decide to go this way instead, tell me if you encounter any issue :)

Sorry again for the inconvenience.

@louiszawadzki louiszawadzki mentioned this issue Jun 24, 2022
4 tasks
@louiszawadzki
Copy link
Contributor

On a side note, please be aware that you might encounter issues when publishing your app with Expo 44.
We do not officially support this version of the SDK as it can require a few changes to deploy your app to the Google Play Store.

I would strongly recommend to update to Expo 45.
If that is not yet possible for you, there is a post on the Expo forum on how to prepare your app for a Google Play Store upload.
We haven't tested it so I cannot guarantee that it works nor that everything is needed. At least iff you're using the latest version of our SDK, you should not need the withKotlinFix.

@louiszawadzki louiszawadzki pinned this issue Jun 24, 2022
@louiszawadzki louiszawadzki changed the title Cannot "disable" Datadog native modules Cannot "disable" Datadog native modules in Expo Go Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants