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 error boundary components and exception logging #22655

Merged
merged 26 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d6202c3
Update `Automattic-Tracks-iOS` pod to point to branch
fluiddot Feb 20, 2024
1cd609b
Add function to log JavaScript exceptions to Crash Logging service
fluiddot Feb 20, 2024
804b772
Add step to copy local bundle
fluiddot Feb 20, 2024
89645c2
Update Gutenberg Mobile reference
fluiddot Feb 21, 2024
edbc5da
Add fastlane step to upload Gutenberg source map
fluiddot Feb 22, 2024
481a47d
Update Gutenberg Mobile reference
fluiddot Feb 23, 2024
9f0b36c
Add build and app_identifier parameters to upload source maps
fluiddot Feb 23, 2024
c034cc5
Use correct app identifier for internal/alpha/prototype builds
fluiddot Feb 23, 2024
6fbfb59
Use callback when logging JS exception
fluiddot Feb 23, 2024
cbc74d2
Upate Podfile.lock
fluiddot Feb 26, 2024
1b900e2
Update Gutenberg Mobile reference
fluiddot Feb 26, 2024
9ea8dbd
Parse JavaScript exception before sending it to the Crash logging ser…
fluiddot Feb 27, 2024
8566c1b
Update Gutenberg Mobile reference and Automattic-Tracks-iOS pod
fluiddot Feb 28, 2024
037244d
Rename JSException param to `message`
fluiddot Feb 29, 2024
f4fd4a8
Update Gutenberg Mobile reference and Automattic-Tracks-iOS pod
fluiddot Mar 1, 2024
18269e4
Merge branch 'trunk' into rnmobile/add/log-exception-to-crash-logging
fluiddot Mar 6, 2024
e58b8b1
Update Podfile.lock
fluiddot Mar 6, 2024
a1a692f
Conform Automattic Tracks protocol for JSException
fluiddot Mar 6, 2024
a355e40
Update `GutenbergJSException` extension
fluiddot Mar 7, 2024
d7cbf8b
Update Gutenberg Mobile reference and Automattic-Tracks-iOS pod
fluiddot Mar 7, 2024
f2791d6
Update release notes
fluiddot Mar 7, 2024
3f5b7cb
Address dangermattic issues
fluiddot Mar 7, 2024
a2259f1
Address dangermattic issues
fluiddot Mar 7, 2024
eb83b4c
Update Tracks to version 3.3
fluiddot Mar 11, 2024
d496af0
Update Podfile.lock
fluiddot Mar 11, 2024
eff477f
Update Gutenberg Mobile reference
fluiddot Mar 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gutenberg/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#
# LOCAL_GUTENBERG=../my-gutenberg-fork bundle exec pod install
ref:
tag: v1.112.0
commit: 6a50374aa5d1dd6475826a61ea0801b61e90fdea
github_org: wordpress-mobile
repo_name: gutenberg-mobile
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ abstract_target 'Apps' do

# Production

pod 'Automattic-Tracks-iOS', '~> 3.0'
# pod 'Automattic-Tracks-iOS', '~> 3.0'
# While in PR
# pod 'Automattic-Tracks-iOS', git: 'https://github.com/Automattic/Automattic-Tracks-iOS.git', branch: ''
pod 'Automattic-Tracks-iOS', git: 'https://github.com/Automattic/Automattic-Tracks-iOS.git', branch: 'add/sentry-js-exception'
# Local Development
# pod 'Automattic-Tracks-iOS', path: '~/Projects/Automattic-Tracks-iOS'

Expand Down
33 changes: 19 additions & 14 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ PODS:
- OHHTTPStubs/Swift (9.1.0):
- OHHTTPStubs/Default
- Reachability (3.2)
- Sentry (8.18.0):
- Sentry/Core (= 8.18.0)
- SentryPrivate (= 8.18.0)
- Sentry/Core (8.18.0):
- SentryPrivate (= 8.18.0)
- SentryPrivate (8.18.0)
- Sentry (8.20.0):
- Sentry/Core (= 8.20.0)
- SentryPrivate (= 8.20.0)
- Sentry/Core (8.20.0):
- SentryPrivate (= 8.20.0)
- SentryPrivate (8.20.0)
- Sodium (0.9.1)
- Starscream (4.0.6)
- SVProgressHUD (2.2.5)
Expand Down Expand Up @@ -99,14 +99,14 @@ DEPENDENCIES:
- AlamofireNetworkActivityIndicator (~> 2.4)
- AppCenter (~> 5.0)
- AppCenter/Distribute (~> 5.0)
- Automattic-Tracks-iOS (~> 3.0)
- Automattic-Tracks-iOS (from `https://github.com/Automattic/Automattic-Tracks-iOS.git`, branch `add/sentry-js-exception`)
- CocoaLumberjack/Swift (~> 3.0)
- CropViewController (= 2.5.3)
- Down (~> 0.6.6)
- FSInteractiveMap (from `https://github.com/wordpress-mobile/FSInteractiveMap.git`, tag `0.2.0`)
- Gifu (= 3.3.1)
- Gridicons (~> 1.2)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.112.0.podspec`)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-6a50374aa5d1dd6475826a61ea0801b61e90fdea.podspec`)
- JTAppleCalendar (~> 8.0.5)
- Kanvas (~> 1.4.4)
- MediaEditor (>= 1.2.2, ~> 1.2)
Expand Down Expand Up @@ -134,7 +134,6 @@ SPEC REPOS:
- AlamofireImage
- AlamofireNetworkActivityIndicator
- AppCenter
- Automattic-Tracks-iOS
- CocoaLumberjack
- CropViewController
- Down
Expand Down Expand Up @@ -169,11 +168,14 @@ SPEC REPOS:
- ZIPFoundation

EXTERNAL SOURCES:
Automattic-Tracks-iOS:
:branch: add/sentry-js-exception
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
FSInteractiveMap:
:git: https://github.com/wordpress-mobile/FSInteractiveMap.git
:tag: 0.2.0
Gutenberg:
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.112.0.podspec
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-6a50374aa5d1dd6475826a61ea0801b61e90fdea.podspec
WordPressAuthenticator:
:commit: fa06fca7178b268d382d91861752b3be0729e8a8
:git: https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git
Expand All @@ -182,6 +184,9 @@ EXTERNAL SOURCES:
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git

CHECKOUT OPTIONS:
Automattic-Tracks-iOS:
:commit: f7920171e01f7b42cca94cefe090940b7e64c8d0
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
FSInteractiveMap:
:git: https://github.com/wordpress-mobile/FSInteractiveMap.git
:tag: 0.2.0
Expand All @@ -204,7 +209,7 @@ SPEC CHECKSUMS:
FSInteractiveMap: a396f610f48b76cb540baa87139d056429abda86
Gifu: 416d4e38c4c2fed012f019e0a1d3ffcb58e5b842
Gridicons: 4455b9f366960121430e45997e32112ae49ffe1d
Gutenberg: ba97dd36571958f64108233a692e6057f5010dc2
Gutenberg: ff644c2a62eda321e735125d931dc27cec98a893
JTAppleCalendar: 16c6501b22cb27520372c28b0a2e0b12c8d0cd73
Kanvas: cc027f8058de881a4ae2b5aa5f05037b6d054d08
MediaEditor: d08314cfcbfac74361071a306b4bc3a39b3356ae
Expand All @@ -213,8 +218,8 @@ SPEC CHECKSUMS:
OCMock: 43565190abc78977ad44a61c0d20d7f0784d35ab
OHHTTPStubs: 90eac6d8f2c18317baeca36698523dc67c513831
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
Sentry: 8984a4ffb2b9bd2894d74fb36e6f5833865bc18e
SentryPrivate: 2f0c9ba4c3fc993f70eab6ca95673509561e0085
Sentry: a8d7b373b9f9868442b02a0c425192f693103cbf
SentryPrivate: 006b24af16828441f70e2ab6adf241bd0a8ad130
Sodium: 23d11554ecd556196d313cf6130d406dfe7ac6da
Starscream: fb2c4510bebf908c62bd383bcf05e673720e91fd
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
Expand All @@ -236,6 +241,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: d170fa8e270b2a32bef9dcdcabff5b8f1a5deced

PODFILE CHECKSUM: cde235b576e5cd0b95b5a64d6bc75628c7adad12
PODFILE CHECKSUM: b2628bd1c79c3a469983ab29ea29b5ef594968b2

COCOAPODS: 1.14.2
5 changes: 5 additions & 0 deletions Scripts/BuildPhases/CopyGutenbergJS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ DEST="$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH"
# Update the matching .inputs.xcfilelist when changing these
XCFRAMEWORK_BUNDLE_ROOT="$PODS_XCFRAMEWORKS_BUILD_DIR/Gutenberg/Gutenberg.framework"
PODS_BUNDLE_ROOT="$PODS_ROOT/Gutenberg/bundle/ios"
LOCAL_BUNDLE="$PODS_ROOT/../../gutenberg-mobile/bundle/ios"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When testing a production version of the JS bundle in local builds, I noticed we don't have a quick way to use a local bundle. For this reason, I added a third option to fetch the bundle by pointing to a local path.

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 option to fetch the bundle form $PODS_ROOT/Gutenberg/bundle/ios seems to be deprecated as the library is provided with the XCFramework. We could remove it.


BUNDLE_FILE="$DEST/main.jsbundle"
BUNDLE_ASSETS="$DEST/assets/"
Expand All @@ -23,6 +24,10 @@ if [[ -d $XCFRAMEWORK_BUNDLE_ROOT ]]; then
elif [[ -d $PODS_BUNDLE_ROOT ]]; then
cp "$PODS_BUNDLE_ROOT/App.js" "$BUNDLE_FILE"
cp -r "$PODS_BUNDLE_ROOT/assets" "$BUNDLE_ASSETS"
elif [[ -d $LOCAL_BUNDLE ]]; then
echo "warning: Using local bundle."
cp "$LOCAL_BUNDLE/App.js" "$BUNDLE_FILE"
cp -r "$LOCAL_BUNDLE/assets" "$BUNDLE_ASSETS"
else
if [[ "$CONFIGURATION" = *Debug* ]]; then
echo "warning: Could not find Gutenberg bundle in either XCFramework or Pods. But running in Debug configuration so will assume you are working with a local version of Gutenberg."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,12 @@ extension GutenbergViewController: PostEditorNavigationBarManagerDelegate {
}
}

func gutenbergDidRequestLogException(_ exception: [AnyHashable: Any], with callback: @escaping () -> Void) {
DispatchQueue.main.async {
WordPressAppDelegate.crashLogging?.logJavaScriptException(exception, callback: callback)
}
}

func navigationBarManager(_ manager: PostEditorNavigationBarManager, closeWasPressed sender: UIButton) {
requestHTML(for: .close)
}
Expand Down
74 changes: 71 additions & 3 deletions fastlane/lanes/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@
dsym_path: lane_context[SharedValues::DSYM_OUTPUT_PATH]
)

upload_gutenberg_sourcemaps(
sentry_project_slug: SENTRY_PROJECT_SLUG_WORDPRESS,
release_version: release_version_current,
build_version: build_code_current,
app_identifier: WORDPRESS_BUNDLE_IDENTIFIER
)
Comment on lines +172 to +177
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This source map will be used for the App Store builds (beta and production) of the WordPress app.


next unless options[:create_release]

archive_zip_path = File.join(PROJECT_ROOT_FOLDER, 'WordPress.xarchive.zip')
Expand Down Expand Up @@ -220,6 +227,13 @@
project_slug: SENTRY_PROJECT_SLUG_JETPACK,
dsym_path: lane_context[SharedValues::DSYM_OUTPUT_PATH]
)

upload_gutenberg_sourcemaps(
sentry_project_slug: SENTRY_PROJECT_SLUG_JETPACK,
release_version: release_version_current,
build_version: build_code_current,
app_identifier: JETPACK_BUNDLE_IDENTIFIER
)
Comment on lines +228 to +233
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This source map will be used for the App Store builds (beta and production) of the Jetpack app.

end

# Builds the "WordPress Internal" app and uploads it to App Center
Expand Down Expand Up @@ -271,6 +285,14 @@
project_slug: SENTRY_PROJECT_SLUG_WORDPRESS,
dsym_path: lane_context[SharedValues::DSYM_OUTPUT_PATH]
)

upload_gutenberg_sourcemaps(
sentry_project_slug: SENTRY_PROJECT_SLUG_WORDPRESS,
release_version: release_version_current_internal,
build_version: build_code_current_internal,
app_identifier: 'org.wordpress.internal'
)
Comment on lines +284 to +289
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This source map will be used for the internal builds of the WordPress app. As far as I checked, this version is seems no longer used.


end

# Builds the WordPress app for a Prototype Build ("WordPress Alpha" scheme), and uploads it to App Center
Expand All @@ -288,7 +310,8 @@
output_app_name: 'WordPress Alpha',
appcenter_app_name: 'WPiOS-One-Offs',
app_icon: ':wordpress:', # Use Buildkite emoji
sentry_project_slug: SENTRY_PROJECT_SLUG_WORDPRESS
sentry_project_slug: SENTRY_PROJECT_SLUG_WORDPRESS,
app_identifier: 'org.wordpress.alpha'
)
end

Expand All @@ -307,7 +330,8 @@
output_app_name: 'Jetpack Alpha',
appcenter_app_name: 'jetpack-installable-builds',
app_icon: ':jetpack:', # Use Buildkite emoji
sentry_project_slug: SENTRY_PROJECT_SLUG_JETPACK
sentry_project_slug: SENTRY_PROJECT_SLUG_JETPACK,
app_identifier: 'com.jetpack.alpha'
)
end

Expand Down Expand Up @@ -339,7 +363,7 @@ def generate_prototype_build_number
# Builds a Prototype Build for WordPress or Jetpack, then uploads it to App Center and comment with a link to it on the PR.
#
# rubocop:disable Metrics/AbcSize
def build_and_upload_prototype_build(scheme:, output_app_name:, appcenter_app_name:, app_icon:, sentry_project_slug:)
def build_and_upload_prototype_build(scheme:, output_app_name:, appcenter_app_name:, app_icon:, sentry_project_slug:, app_identifier:)
configuration = 'Release-Alpha'

# Get the current build version, and update it if needed
Expand Down Expand Up @@ -394,6 +418,13 @@ def build_and_upload_prototype_build(scheme:, output_app_name:, appcenter_app_na
dsym_path: lane_context[SharedValues::DSYM_OUTPUT_PATH]
)

upload_gutenberg_sourcemaps(
sentry_project_slug: sentry_project_slug,
release_version: release_version_current,
build_version: build_number,
app_identifier: app_identifier
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This source map will be used for the alpha builds (i.e. installable builds in PRs). The app is determined by the app_identifier parameter.


# Post PR Comment
comment_body = prototype_build_details_comment(
app_display_name: output_app_name,
Expand Down Expand Up @@ -450,4 +481,41 @@ def upload_build_to_testflight(whats_new_path:)
changelog: File.read(whats_new_path)
)
end

def upload_gutenberg_sourcemaps(sentry_project_slug:, release_version:, build_version:, app_identifier:)
# The bundle and source map files are the same for all architectures.
gutenberg_bundle = File.join(PROJECT_ROOT_FOLDER, "Pods/Gutenberg/Frameworks/Gutenberg.xcframework/ios-arm64/Gutenberg.framework")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As specified in the inline comment, the bundle and source map files are included for each architecture. However, both files are the same, as the JavaScript code isn't affected by the architecture. Hence, we can use the files from any of the architectures.


Dir.mktmpdir do |sourcemaps_folder|
# It's important that the bundle and source map files have specific names, otherwise, Sentry
# won't symbolicate the stack traces.
FileUtils.cp(File.join(gutenberg_bundle, 'App.js'), File.join(sourcemaps_folder, 'main.jsbundle'))
FileUtils.cp(File.join(gutenberg_bundle, 'App.composed.js.map'), File.join(sourcemaps_folder, 'main.jsbundle.map'))

# To generate the full release version string to attach the source maps, we need to specify:
# - App identifier
# - Release version
# - Build version
# This conforms to the following format: <app_identifier>@<release_version>+<build_version>
# Here are a couple of examples:
# - Prototype build: com.jetpack.alpha@24.2+pr22654-07765b3 
# - App Store build: org.wordpress@24.1+24.1.0.3

sentry_upload_sourcemap(
auth_token: get_required_env('SENTRY_AUTH_TOKEN'),
org_slug: SENTRY_ORG_SLUG,
project_slug: sentry_project_slug,
version: release_version,
dist: build_version,
build: build_version,
app_identifier: app_identifier,
# When the React native bundle is generated, the source map file references
# include the local machine path, with the `rewrite` and `strip_common_prefix`
# options Sentry automatically strips this part.
rewrite: true,
strip_common_prefix: true,
sourcemap: sourcemaps_folder
)
end
end
end