DataDog / expo-datadog

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

Ability to build without talking to datadog api #2

Open Nicktho opened 1 year ago

Nicktho commented 1 year ago

Is your feature request related to a problem? Please describe. In the documentation for crash reporting (https://github.com/DataDog/dd-sdk-reactnative/blob/develop/docs/expo_crash_reporting.md#disable-file-uploads ), it appears that by changing config you can disable file uploads to the datadog api.

Although, when setting these config options and running an ios build locally (expo run:ios), an error message saying "datadog-ci" package is required and then upon installing that package and re-running the build, another error message will show regarding the environment variable DATADOG_API_KEY missing.

It is unclear from the documentation that it is always required to install @datadog/datadog-ci and have DATADOG_API_KEY set as an environment variable.

It is also perhaps not ideal for all teams to have that API key locally for engineers wanting to build their ios project locally with expo run:ios

Describe the solution you'd like

aaronholla commented 6 months ago

For anyone else looking to disable all uploads only in local dev.

The documentation now mentions

If you want to disable all file uploads, remove the expo-datadog from the list of plugins.

I wanted to add to this to describe an approach that works for expo apps.

You have the option to conditionally include the plugin based on the environment. This will require utilizing the dynamic expo config file (https://docs.expo.dev/workflow/configuration/#dynamic-configuration)

As an example, you could utilize the CI env variable to only upload when building in CI:

// app.config.js

module.exports = {
  plugins: [
    ...(process.env.CI ? ['expo-datadog'] : []),
    <Other Plugins>
  ],
};

If using Expo EAS to build you can also utilize their built in env variables to upload for only specific build profiles or platforms. (https://docs.expo.dev/build-reference/variables/#built-in-environment-variables)