sentry-fastlane-plugin icon indicating copy to clipboard operation
sentry-fastlane-plugin copied to clipboard

Use with RAM bundle?

Open christhegrand opened this issue 5 years ago • 5 comments

We're using this plugin to upload our index.android.bundle and index.android.bundle.map files to Sentry as part of our CI build. We recently added bundleCommand: "ram-bundle" to our Gradle file's React options, and our Android stack traces are no longer getting symbolicated properly in Sentry. Here's an example. Here's the upload code we're currently using:

      files.each do |file|
        puts "Uploading #{file}"
        if file.end_with?('.map')
          sentry_upload_sourcemap(
            auth_token: ENV['SENTRY_AUTH_TOKEN'],
            org_slug: ENV['SENTRY_ORG'],
            project_slug: ENV['SENTRY_PROJECT'],
            version: version_name,
            app_identifier: application_id,
            dist: version_code,
            strip_common_prefix: true,
            sourcemap: file,
            rewrite: true
          )
        else
          sentry_upload_file(
            auth_token: ENV['SENTRY_AUTH_TOKEN'],
            org_slug: ENV['SENTRY_ORG'],
            project_slug: ENV['SENTRY_PROJECT'],
            version: version_name,
            app_identifier: application_id,
            dist: version_code,
            file: file,
            file_url: '~/' + file.split('/')[-1]
          )
        end
      end

Is there an additional parameter I should be passing in to these functions in order to get properly symbolicated stack traces in Sentry?

christhegrand avatar Oct 04 '19 20:10 christhegrand

Hey @christhegrand,

sorry for abandoning the issue. Do you still experience the problem? Did you find a workaround?

philipphofmann avatar Apr 20 '22 09:04 philipphofmann

I ended up rewriting the code to call the API by hand and did get it to work, although I think we did still have intermittent issues every once in a while with some files not getting symbolicated (the product I needed this for is no longer under active development). Here's what I wrote, in case it helps someone out in the future:

    # The Sentry Fastlane library doesn't seem to properly upload ram-bundle files.
    # So if we detect those, upload the app bundle and sourcemap by calling the API manually through Ruby - yuck
    # Here's an attempt to do the right thing in every scenario
    release_id = "#{application_id}@#{version_name}"
    sh("sentry-cli", "releases", "new", release_id)

    files = []

    # The RAM-bundle sourcemaps use extensions created by Facebook called x_facebook_offsets. If we detect that
    # extension inside the sourcemap, we have a ram-bundle.
    if system("grep -q x_facebook_offsets #{mailworker_sourcemap}")
      system("sentry-cli releases files #{release_id} upload-sourcemaps --dist #{ENV['BAGEL_CLIENT_HASH']} --bundle #{mailworker_bundle} --bundle-sourcemap #{mailworker_sourcemap}")
    else
      files.push(mailworker_bundle, mailworker_sourcemap)
    end

    if system("grep -q x_facebook_offsets #{app_sourcemap}")
      system("sentry-cli releases files #{release_id} upload-sourcemaps --dist #{ENV['BAGEL_CLIENT_HASH']} --bundle #{app_bundle} --bundle-sourcemap #{app_sourcemap}")
    else
      files.push(app_bundle, app_sourcemap)
    end

    # Otherwise, we can rely on the Fastlane Sentry library for uploads to Sentry
    files.each do |file|
      puts "Uploading #{file}"
      if file.end_with?('.map')
        sh("sentry-cli", "releases", "files", release_id, "upload-sourcemaps", file, '--dist', "#{ENV['BAGEL_CLIENT_HASH']}", "--strip-common-prefix", "--rewrite")
      else
        sh("sentry-cli", "releases", "files", release_id, "upload", file, '~/' + file.split('/')[-1], '--dist', "#{ENV['BAGEL_CLIENT_HASH']}")
      end
    end
  end

christhegrand avatar Apr 20 '22 13:04 christhegrand

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar May 20 '22 00:05 github-actions[bot]

Does it make sense to close this one now? Wouldn't Hermes be the advised way or is RAM bundles still a thing? @krystofwoldrich might be able to help here

bruno-garcia avatar Sep 20 '22 14:09 bruno-garcia

If @krystofwoldrich agrees, I'm happy to close this issue.

philipphofmann avatar Sep 20 '22 16:09 philipphofmann