Skip to content

Unable to get replay session when integrating both reactNavigationIntegration() & mobileReplayIntegration() #5074

@InterstellarStella

Description

@InterstellarStella

What React Native libraries do you use?

React Navigation

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.19.0

How does your development environment look like?

"dependencies": {
    "@react-navigation/native": "^6.1.9",
    "@sentry/react-native": "^6.19.0",
    "react": "19.0.0",
    "react-native": "0.78.2"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@babel/preset-env": "^7.25.3",
    "@babel/runtime": "^7.25.0",
    "@react-native-community/cli": "15.0.1",
    "@react-native-community/cli-platform-android": "15.0.1",
    "@react-native-community/cli-platform-ios": "15.0.1",
    "@react-native/babel-preset": "0.78.2",
    "@react-native/eslint-config": "0.78.2",
    "@react-native/metro-config": "0.78.2",
    "@react-native/typescript-config": "0.78.2",
    "@types/jest": "^29.5.13",
    "@types/react": "^19.0.0",
    "@types/react-test-renderer": "^19.0.0",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "19.0.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }



Sentry.init()

import React, {useRef} from 'react';
import {Button, View} from 'react-native';
import * as Sentry from '@sentry/react-native';
import {NavigationContainer} from '@react-navigation/native';

export const navigationIntegration = Sentry.reactNavigationIntegration({
  enableTimeToInitialDisplay: true,
});

const configureSentry = () => {
  Sentry.init({
    dsn: 'YOUR_DSN',
    tracesSampleRate: 0.2,
    environment: 'development',
    appHangTimeoutInterval: 10,
    enableUserInteractionTracing: true,
    replaysSessionSampleRate: 0.0, // No need to record full session
    replaysOnErrorSampleRate: 1.0, // Record a replay for 100% of error sessions
    integrations: [
      Sentry.mobileReplayIntegration({
        maskAllText: false,
        maskAllImages: false,
        maskAllVectors: false,
      }),
      Sentry.reactNativeTracingIntegration(),
      navigationIntegration,
    ],
  });
};

configureSentry();

function App(): React.JSX.Element {
  const containerRef = useRef(null);

  return (
    <NavigationContainer
      ref={containerRef}
      onReady={() => {
        navigationIntegration.registerNavigationContainer(containerRef);
      }}>
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
        <Button
          title="Test Crash"
          // Having sentry-label will affect the sentry replay session
          // with sentry-label, iOS not able to record replay session
          // Android totally not able to record replay session
          sentry-label="DISABLE_REPLAY"
          onPress={() => {
            throw new Error('Test Crash New App Replay');
          }}
        />
      </View>
    </NavigationContainer>
  );
}

export default Sentry.wrap(App);

Steps to Reproduce

If we remove reactNavigationIntegration in integrations array or remove the navigationIntegration.registerNavigationContainer(ref); function call in NavigationContainer onReady(), all the force crash test will be recorded successfully & consistently.
We have tested that it is the navigationIntegration.registerNavigationContainer(ref); that caused the error replay session not show up in Dashboard.
This happens in iOS. Android replay session somehow doesn't work at all.

Expected Result

Replays are recorded normally.

Actual Result

By adding sentry-label prop to React Native Button component, the replay session will not be recorded and uploaded to Sentry dashboard. This breaks iOS & Android all together. even when replaysOnErrorSampleRate: 1.0

This is an escalation from Zendesk. Debug logs and ticket history can be found in the linked Linear issue.

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions