Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gutenberg] Add Sentry React native SDK #16700

Closed
wants to merge 24 commits into from

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented Jun 17, 2021

gutenberg-mobile PR: wordpress-mobile/gutenberg-mobile#3629
gutenberg PR: WordPress/gutenberg#32768
Automattic-Tracks-iOS PR: Automattic/Automattic-Tracks-iOS#183

To test:
Follow the testing instructions from gutenberg PR: WordPress/gutenberg#32768

Regression Notes

  1. Potential unintended areas of impact
    The lanes (Fastfile) related to building and uploading the build as they're using a new lane I've added for uploading the source maps to Sentry.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    I manually tested the lane by running the command bundle exec fastlane upload_gutenberg_sourcemaps internal:true but I haven't tested the ones related to building and uploading builds.

  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@fluiddot fluiddot self-assigned this Jun 17, 2021
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jun 17, 2021

You can trigger an installable build for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jun 17, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@fluiddot fluiddot added the Gutenberg Editing and display of Gutenberg blocks. label Jun 17, 2021
Comment on lines 935 to 937
DispatchQueue.main.async {
WordPressAppDelegate.crashLogging?.logEnvelope(envelope)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calls to WordPressAppDelegate are required to be done in the main thread.

fastlane/Fastfile Outdated Show resolved Hide resolved
Comment on lines 694 to 695
FileUtils.cp(File.join(gutenberg_bundle, 'App.js'), File.join(sourcemaps_folder, 'main.jsbundle'))
FileUtils.cp(File.join(gutenberg_bundle, 'App.js.map'), File.join(sourcemaps_folder, 'main.jsbundle.map'))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important that the source map files have specific names, otherwise, Sentry doesn't un-minify the stack traces.

# bundle exec fastlane upload_gutenberg_sourcemaps internal:true
#####################################################################################
lane :upload_gutenberg_sourcemaps do | options |
build_version = ios_get_build_version(internal: options[:internal])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build version is different depending on the internal option, here is an example:

@fluiddot fluiddot marked this pull request as ready for review June 24, 2021 10:43
@fluiddot
Copy link
Contributor Author

@mokagio @jkmassel I've added a new lane to the Fastfile to upload the React native source maps to Sentry, I'd appreciate it if you could take a look at that part just in case I'm overlooking anything, thanks 🙇 !

Copy link

@antonis antonis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested via WordPress/gutenberg#32768 (review)
The code changes LGTM too 🎉

@fluiddot fluiddot requested review from mokagio and jkmassel June 25, 2021 15:31
Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for jumping into adding logic to the Fastlane automation @fluiddot 👏 🙇‍♂️

I only left nitpick / minor improvement comments

fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
sourcemap: sourcemaps_folder
)

FileUtils.rm_rf(sourcemaps_folder)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruby suggestion: there's a way to run this code that depends on a temporary directory in a block, so that even if something fails, the runtime will ensure the directory is removed.

It should be something like:

require 'tmpdir'

Dir.mktmpdir do |sourcemaps_folder|
  # all the code should "just work" the way it's written right now
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion 🙇 ! I'll update the code to use the temporary directory block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied your suggestion in this commit and run some tests, it worked like charm 🎊 .

Comment on lines 714 to 715
version: build_version,
dist: build_version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check, what's the difference between these two parameters and why is it okay for them to have the same value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are documented here, the version value should match the one set here. However, I'm not sure about what to use for dist, when I checked Sentry events, I found that they had the same value (see attached examples) so I went ahead and use the same version value.

Screenshot 2021-07-01 at 12 48 22

I've just checked from where the Sentry iOS SDK takes the dist value (code reference) and it's CFBundleVersion, so looks like that in the end it's actually the same value 😄 . One thing I could try is to remove the dist parameter from the action and check if it affects somehow 👍.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done a test by removing the dist parameter and so far it works, however, this change also implies initializing the SDK in the RN side without that parameter (code reference).

To be honest, I don't have a strong opinion on whether include it or not, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fluiddot I dug a bit into the documents and found a definition of what the dist value is meant to be here which matches your finding:

You will also need to pass a distribution to dist for events to be attributed correctly to a release. Usually this value is the build number, for example 52. This value needs to be unique to only each release.

Given that, your original approach of passing the build number was spot on.

The snippet in that pages shows the release as something that looks more like a node module name that the build number

Sentry.init({
  release: "[email protected]",
  dist: "52",
});

I guess they're making a bit of confusion on their end between release, dist, version, and build in the attempt of supporting different platforms? 🤷‍♂️

From what I see in your explanation and screenshots, this setup seems fine. 👍

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jul 5, 2021

Fails
🚫 Podfile: reference to a commit hash

Generated by 🚫 dangerJS

@fluiddot
Copy link
Contributor Author

fluiddot commented Jul 5, 2021

As posted in this comment, the Sentry native module has been moved to the WordPress-iOS project.

@fluiddot fluiddot requested a review from mchowning July 9, 2021 12:13
@twstokes
Copy link
Contributor

👋 I'm going to close this PR due to lack of activity, but please reopen if this was an error. Thank you.

@twstokes twstokes closed this Aug 25, 2023
@jkmassel jkmassel deleted the gutenberg/add/sentry-react-native branch July 26, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants