Skip to content

Hybrid App [iOS with RN] : React Native screens RUM data is not sent to DataDog . Issue in iOS . Works for Android . Could not see RUM sent message in logs. #682

@kesavarao-EB

Description

@kesavarao-EB

Describe the bug

We have native apps (iOS and android) and DataDog RUM already been instrumented and working fine. We recently developed some screens using react native (FYI, React native code resides in a separate repo).

[ios app with RN] -Native APP is the main and some of pages are based out react-native.

GOAL - Instrument DataDog RUM for react native screens or project.

We followed this DOC and also example repo (ios-with-rn)

ISSUE - [in iOS] RUM data of react native screens are NOT sent to Datadog for iOS. Could not find under Digital Experience -> RUM -> Performance summary .

NOTE - Same code working in "ANDROID", we can see the custom view name being displayed in Datadog RUM under Android application.

below is my DataDogRUM initialisation code in both iOS and react-native repo

Ios :

In AppDelegate.swift,
`.run { _ in

                let configuration = Datadog.Configuration(
                    clientToken: "<Correct Value passed>",
                    env: "alpha",
                    site: .us1
            
                )
                
                print("=======Datadog initializing============")
                Datadog.initialize(with: configuration, trackingConsent: .granted)
                  
                let rumConfiguration = RUM.Configuration(
                    applicationID: "<passed iOS app id>",
                    sessionSampleRate: 100, uiKitViewsPredicate:RNHybridPredicate(),
                    uiKitActionsPredicate: DefaultUIKitRUMActionsPredicate(),
                    urlSessionTracking: RUM.Configuration.URLSessionTracking()
                )
              
                RUM.enable(with: rumConfiguration)
                Datadog.verbosityLevel = .debug 
                
                print("=======Datadog initialized============")`
                
                
       ` class RNHybridPredicate: UIKitRUMViewsPredicate {
                  var defaultPredicate = DefaultUIKitRUMViewsPredicate()

                    func rumView(for viewController: UIViewController) -> RUMView? {
                          // Dropping RN Views here as they are caught from 
                              let canonicalClassName = NSStringFromClass(type(of: viewController))
                               if (canonicalClassName.starts(with: "RN")) {
                             return nil
                          }
    
                 return defaultPredicate.rumView(for: viewController)
               }
               }`

In react-native app repo :

index.tsx

       `
 `function initializeDatadogRum() {
console.log('=====initializeDatadogRum=====');
return DatadogProvider.initialize({
    clientToken: 'Dummy Value',
    env: 'Dummy Value',
    applicationId: 'Dummy Value',
    longTaskThresholdMs: 100,
    sessionSamplingRate: 100,
    serviceName: '==== custom service Name ====',
    verbosity: SdkVerbosity.DEBUG,
});

}`

`export function App(props: Props) {
const [data, setData] = useState<SectionData[]>([]);

useEffect(() => {
    initializeDatadogRum();`
    

`const config = {
    trackResources: true,
    trackErrors: true,
    trackInteractions: true,
};`

` return (
      <DatadogProvider configuration={config}>
        <View style={styles.background}>
            <NavigationContainer
                ref={navigationRef}
                onReady={() => {
                    DdRum.startView('Manual Key', '-=====Custom Action ========');`

`

Reproduction steps

Initialize RUM as above

Open project in Xcode

Run the app in simulator

Navigate to native screens and react native screens

Go to Datadog RUM dashboard and looks for view names of react native screens.

SDK logs

======Datadog initialized============
[DATADOG SDK] 🐶 → 18:54:06.753 NTP time synchronization completed.
🔥 Datadog SDK usage error: The 'main' instance of SDK is already initialized.

DATADOG: Starting RUM Resource #1719669770474/GET GET: https://codepush.appcenter.ms/v0.1/public/codepush/update_check?deployment_key=PL&app_version=9.82.0&package_hash=b6fa7ea2f54828629&label=v250&client_unique_id=2E3B58C5-BC0B-****-8CDD-00000000000000
DATADOG: Stopping RUM Resource #1719669770474/GET status:200

Not Getting

Batch *********** [4345 bytes] (RUM Request) sent successfully.

Which we are seeing for Android

Expected behavior

No response

Affected SDK versions

"@datadog/mobile-react-native": "^2.3.5", "@datadog/mobile-react-native-navigation": "^2.3.5", "@datadog/mobile-react-navigation": "^2.3.5", dd-sdk-ios : 2.5.0

Latest working SDK version

mobile-react-navigation": "^2.3.5", dd-sdk-ios : 2.5.0

Did you confirm if the latest SDK version fixes the bug?

Yes

Integration Methods

NPM

React Native Version

0.73.4

Package.json Contents

No response

iOS Setup

No response

Android Setup

No response

Device Information

No response

Other relevant information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions