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 22 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.115.0-alpha3
commit: 39749cc4fcc1176074c1550e3645ae814a174750
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 @@ -131,9 +131,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.21.0):
- Sentry/Core (= 8.21.0)
- SentryPrivate (= 8.21.0)
- Sentry/Core (8.21.0):
- SentryPrivate (= 8.21.0)
- SentryPrivate (8.21.0)
- Sodium (0.9.1)
- Starscream (4.0.6)
- SVProgressHUD (2.2.5)
Expand Down Expand Up @@ -98,14 +98,14 @@ DEPENDENCIES:
- AlamofireNetworkActivityIndicator (~> 3.0)
- 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.115.0-alpha3.podspec`)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-39749cc4fcc1176074c1550e3645ae814a174750.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 @@ -170,13 +169,19 @@ 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.115.0-alpha3.podspec
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-39749cc4fcc1176074c1550e3645ae814a174750.podspec

CHECKOUT OPTIONS:
Automattic-Tracks-iOS:
:commit: d3694e8a352f8cac3f3c26f73125614408c01abc
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
FSInteractiveMap:
:git: https://github.com/wordpress-mobile/FSInteractiveMap.git
:tag: 0.2.0
Expand All @@ -193,7 +198,7 @@ SPEC CHECKSUMS:
FSInteractiveMap: a396f610f48b76cb540baa87139d056429abda86
Gifu: 416d4e38c4c2fed012f019e0a1d3ffcb58e5b842
Gridicons: 4455b9f366960121430e45997e32112ae49ffe1d
Gutenberg: c8aaa59f24cf3e5618a02d1a4f0c48db9981c3dd
Gutenberg: 9926783a31efe04e7b72729c76f897e187974a91
JTAppleCalendar: 16c6501b22cb27520372c28b0a2e0b12c8d0cd73
Kanvas: cc027f8058de881a4ae2b5aa5f05037b6d054d08
MediaEditor: d08314cfcbfac74361071a306b4bc3a39b3356ae
Expand All @@ -202,8 +207,8 @@ SPEC CHECKSUMS:
OCMock: 43565190abc78977ad44a61c0d20d7f0784d35ab
OHHTTPStubs: 90eac6d8f2c18317baeca36698523dc67c513831
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
Sentry: 8984a4ffb2b9bd2894d74fb36e6f5833865bc18e
SentryPrivate: 2f0c9ba4c3fc993f70eab6ca95673509561e0085
Sentry: ebc12276bd17613a114ab359074096b6b3725203
SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe
Sodium: 23d11554ecd556196d313cf6130d406dfe7ac6da
Starscream: fb2c4510bebf908c62bd383bcf05e673720e91fd
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
Expand All @@ -225,6 +230,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: d170fa8e270b2a32bef9dcdcabff5b8f1a5deced

PODFILE CHECKSUM: e3e8f913d1e22d005cc0c351141a3055d6f23cca
PODFILE CHECKSUM: 0b1acbd2a6c822646627ded7f6aa4e7e03076cac

COCOAPODS: 1.14.2
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [**] [internal] Block editor: Upgrade React Native to version 0.73.3 [#22588]
* [*] Remove "Edit" button from "Post Published" screen [#22762]
* [*] Remove "Publish" button from "Preview" screen [#22763]
* [**] Block editor: Add error boundary components and exception logging [#22655]

24.4
-----
Expand Down
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 @@ -3,6 +3,7 @@ import Gutenberg
import Aztec
import WordPressFlux
import React
import AutomatticTracks

class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelegate, PublishingEditor {
let errorDomain: String = "GutenbergViewController.errorDomain"
Expand Down Expand Up @@ -1295,6 +1296,12 @@ extension GutenbergViewController: PostEditorNavigationBarManagerDelegate {
}
}

func gutenbergDidRequestLogException(_ exception: GutenbergJSException, 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 Expand Up @@ -1378,3 +1385,7 @@ extension GutenbergViewController {
})
}
}

// Extend Gutenberg JavaScript exception struct to conform the protocol defined in the Crash Logging service
extension GutenbergJSException.StacktraceLine: AutomatticTracks.JSStacktraceLine {}
extension GutenbergJSException: AutomatticTracks.JSException {}
75 changes: 72 additions & 3 deletions fastlane/lanes/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,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 @@ -217,6 +224,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 @@ -266,6 +280,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.


fluiddot marked this conversation as resolved.
Show resolved Hide resolved
end

# Builds the WordPress app for a Prototype Build ("WordPress Alpha" scheme), and uploads it to App Center
Expand All @@ -283,7 +305,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 @@ -302,7 +325,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 @@ -334,7 +358,8 @@ 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:)
# rubocop:disable Metrics/ParameterLists
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 @@ -385,6 +410,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:,
release_version: release_version_current,
build_version: build_number,
app_identifier:
)

# Post PR Comment
comment_body = prototype_build_details_comment(
app_display_name: output_app_name,
Expand Down Expand Up @@ -464,4 +496,41 @@ def upload_build_to_app_center(
notify_testers: false
)
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')

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: [email protected]+pr22654-07765b3
# - App Store build: [email protected]+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:,
# 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
Loading