이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Overview

By default, the React Native SDK initializes the native SDK when calling DdSdkReactNative.initialize(config) on the JS layer, or using the DatadogProvider. As a result, the SDK does not capture native crashes that occur prior to the initialization being called on the JS layer. Starting from v2.3.0, you can initialize your native SDK in order for Datadog to capture any crashes before the React Native layer starts.

Configuration

To initialize your native SDK before React Native has started:

  1. Create a datadog-configuration.json file at the root of the react-native project with the following structure:

    {
      "$schema": "./node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json",
      "configuration": {
      }
    }
    

    The "$schema" attribute here enables autocomplete and helps most modern Integrated Development Environments (IDE) to show errors if the configuration is incomplete or invalid.

    You may see an error in your IDE if the configuration is incomplete or invalid
    You may see an error in your IDE if the configuration is incomplete or invalid
    You may see an error in your IDE if the configuration is incomplete or invalid
  2. Follow the steps below for your native OS.

    1. Add the following snippet to the MainApplication.kt file:

      import com.datadog.reactnative.DdSdkNativeInitialization
      
      class MainApplication : Application(), ReactApplication {
        override fun onCreate() {
          super.onCreate()
          DdSdkNativeInitialization.initFromNative(this.applicationContext)
          // Rest of the method
        }
      }
      
    2. Add the following snippet to the android/app/build.gradle file:

      apply from: "../../node_modules/@datadog/mobile-react-native/datadog-configuration.gradle"
      

      This script copies the configuration file to your build assets directory.

    1. Add the following snippet to the AppDelegate.mm file:

      // Add this import
      #import "DdSdk.h"
      
      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
          [DdSdk initFromNative];
          // rest of the function
      }
      
    2. Add the datadog-configuration.json file to your project resources.

    Change the Datadog initialization to read from the same file to ensure consistency:

    const configuration  = new FileBasedConfiguration(require("./datadog-configuration.json"))
    
    <DatadogProvider configuration={configuration}>
      // Rest of the app
    </DatadogProvider>
    

Configuration file location

Depending on your OS, the configuration file may be in a different location:

  • In Android, you can specify where to get the file to copy by adding the following snippet:

    project.ext.datadog = [
        configurationFilePath: "../../../datadog-configuration.json"
    ]
    
  • In iOS, the configuration file gets added to the top of the project resources directory, no matter where it is located.

  • In React Native, you can specify any path for the file using the require pattern.

Further Reading

추가 유용한 문서, 링크 및 기사:

PREVIEWING: Cyril-Bouchiat/add-vm-package-explorer-doc