getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 332 forks source link

Unsymbolicated sentry stack traces #4118

Open jayshah123 opened 2 days ago

jayshah123 commented 2 days ago

OS:

Platform:

SDK:

SDK version: @sentry/react-native@5.20.0

react-native version: 0.73.9

Are you using Expo?

Are you using sentry.io or on-premise?

If you are using sentry.io, please post a link to your issue so we can take a look:

Link to issue

Configuration:

(@sentry/react-native)

  Sentry.init({
    dsn: SENTRY_DSN,
    environment: ENVIRONMENT,
    release: `${appJson.version}-${appJson.jsVersion}`,
    dist: `${appJson.versionCode}`,
    beforeSend: sentryFilter,
    enableTracing: false,
    attachStacktrace: true,
    enableWatchdogTerminationTracking: true,
    enableAutoPerformanceTracing: false,
  });

In our metro.config.js, we use @expo/metro-config as a starting point like below:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */
const { getDefaultConfig } = require('@expo/metro-config');

const path = require('path');

async function getConfig(appDir) {
  const config = await getDefaultConfig(__dirname);
  // setup watch folders
  config.watchFolders = [path.resolve(appDir, 'node_modules')];
  // setup transformer
  config.transformer = {
    ...config.transformer,
    babelTransformerPath: require.resolve('react-native-svg-transformer/expo'),
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: true,
        inlineRequires: true,
      },
    }),
  };

  // setup resolver source extensions
  const originalSourceExts = config.resolver.sourceExts;
  let newSourceExts = process.env.RN_SRC_EXT
    ? process.env.RN_SRC_EXT.split(',').concat(originalSourceExts)
    : originalSourceExts;
  config.resolver.sourceExts = [...newSourceExts, 'svg', 'cjs', 'mjs'];

  // setup resolver asset extensions
  const origianlAssetExts = config.resolver.assetExts;
  config.resolver.assetExts = [
    ...origianlAssetExts.filter((ext) => ext !== 'svg'),
    'css',
    'scss',
  ];

  return config;
}

module.exports = getConfig(__dirname);

Upload steps for iOS (after codepush release-react):

                export SENTRY_PROPERTIES=./ios/sentry.properties
                npx react-native bundle --dev false --platform ios --entry-file index.js --bundle-output main.jsbundle --sourcemap-output main.jsbundle.map
                node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite main.jsbundle main.jsbundle.map --dist $VERSIONCODE

Upload steps for Android (after codepush release-react):

                export SENTRY_PROPERTIES=./ios/sentry.properties
                npx react-native bundle --dev false --platform android --entry-file index.js --bundle-output index.android.bundle --sourcemap-output index.android.bundle.map
                node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite index.android.bundle index.android.bundle.map --dist $VERSIONCODE

I have the following issue:

[Description]

  1. I have correct debugId appended in js bundle during release and same source/sourcemap is found in sentry.io.
  2. I don't see any "debugId" field in index.android.bundle.map json file.
  3. Currently # debugId comment in minified code bundle seems to be coming from: node_modules/@expo/metro-config/build/serializer/fork/baseJSBundle.js

Steps to reproduce:

Actual result:

Unsymbolicated stack trace

Expected result:

Symbolicated stack trace.

lucas-zimerman commented 2 days ago

Hi and thank you for opening this issue! Could you please share the commands you use to build the native app (both for iOS and Android)?

jayshah123 commented 1 day ago

The android native release happens through fastlane:

bundle exec fastlane android release_playstore
# upload sentry sourcemaps
export SENTRY_PROPERTIES=./android/sentry.properties
 npx react-native bundle --dev false --platform android --entry-file index.js --bundle-output index.android.bundle --sourcemap-output index.android.bundle.map
node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite index.android.bundle index.android.bundle.map --dist $VERSIONCODE

Here are the contents of lane:

    desc "Build and upload the app to playstore for production release"
    lane :release_playstore do
        # Upload Android App Bundle to PlayStore
        upload_to_play_store(
            skip_upload_apk: true,
            skip_upload_metadata: true,
            skip_upload_changelogs: true,
            skip_upload_images: true,
            skip_upload_screenshots: true,
            aab: './android/app/build/outputs/bundle/release/app-release.aab',
            rollout: '0.1',
        )
    end

iOS native release also happens through fastlane

bundle exec fastlane ios build_appstore
bundle exec fastlane ios release_appstore
# upload sentry stuff
export SENTRY_PROPERTIES=./ios/sentry.properties
npx react-native bundle --dev false --platform ios --entry-file index.js --bundle-output main.jsbundle --sourcemap-output main.jsbundle.map
node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite main.jsbundle main.jsbundle.map --dist $VERSIONCODE
bundle exec fastlane upload_debug_symbols_sentry_ios

Contents of fastlane:

  private_lane :publish_appstore do
    api_key = app_store_connect_api_key(
      key_id: ENV['APP_STORE_KEY_ID'],
      issuer_id: ENV['APP_STORE_ISSUER_ID'],
      key_filepath: ENV['APP_STORE_KEY_FILEPATH'],
      duration: 1200,
      in_house: false
    )

    upload_to_app_store(
      app_version: ENV['VERSION'],
      app_identifier: APP_ID,
      api_key: api_key,
      ipa: IPA_PATH,
      submit_for_review: true,
      automatic_release: false,
      skip_metadata: false,
      skip_screenshots: true,
      force: true,
      run_precheck_before_submit: false,
      # verify_only: true,
      submission_information: {
        add_id_info_uses_idfa: false
      },
      release_notes: {
        "default": 'Bug Fixes and Improvements',
        "en-US": 'Bug Fixes and Improvements'
      },
      phased_release: true
    )
  end
kahest commented 1 day ago

Thanks @jayshah123 for the detailled response, we'll investigate and follow up here.

jayshah123 commented 1 day ago

Thanks @kahest . There is one more issue around: App Hanging - "Sentry has identified the following problems for you to fix: A required debug information file was missing". Should I raise a separate issue? Or provide the issue link in this same thread?

kahest commented 1 day ago

@jayshah123 a link would be appreciated. We can keep it in this current issue until we know if it's a separate one

jayshah123 commented 1 day ago

Link to the second issue here