From d923fa01127dd899ac85e7f9a3434336f5c8f25b Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 30 Sep 2024 22:48:53 +0200 Subject: [PATCH 01/10] misc: Move macos sample to a standalone project --- .github/workflows/sample-application.yml | 2 +- package.json | 1 + samples/react-native-macos/.eslintrc.js | 17 + samples/react-native-macos/.gitignore | 65 ++++ samples/react-native-macos/.prettierrc.js | 7 + samples/react-native-macos/.watchmanconfig | 1 + samples/react-native-macos/Gemfile | 8 + samples/react-native-macos/Gemfile.lock | 284 +++++++++++++++++ samples/react-native-macos/_bundle/config | 2 + samples/react-native-macos/app.json | 4 + samples/react-native-macos/babel.config.js | 4 + samples/react-native-macos/index.js | 10 + .../macos/.gitignore | 0 .../macos/.xcode.env | 0 .../macos/Podfile | 0 .../macos/PrivacyInfo.xcprivacy | 37 +++ .../AppDelegate.h | 0 .../AppDelegate.mm | 0 .../AppIcon.appiconset/128-mac.png | Bin .../AppIcon.appiconset/16-mac.png | Bin .../AppIcon.appiconset/256-mac 1.png | Bin .../AppIcon.appiconset/256-mac.png | Bin .../AppIcon.appiconset/32-mac 1.png | Bin .../AppIcon.appiconset/32-mac.png | Bin .../AppIcon.appiconset/512-mac.png | Bin .../AppIcon.appiconset/64-mac.png | Bin .../AppIcon.appiconset/Contents.json | 0 .../AppIcon.appiconset/iTunesArtwork@1x.png | Bin .../AppIcon.appiconset/iTunesArtwork@2x.png | Bin .../Assets.xcassets/Contents.json | 0 .../Base.lproj/Main.storyboard | 0 .../Info.plist | 0 .../sentry-react-native-sample-macOS/main.m | 0 .../sentry-react-native-sample.entitlements | 0 .../project.pbxproj | 10 +- .../sentry-react-native-sample-macOS.xcscheme | 0 .../contents.xcworkspacedata | 0 .../xcshareddata/IDEWorkspaceChecks.plist | 0 samples/react-native-macos/metro.config.js | 70 +++++ samples/react-native-macos/package.json | 62 ++++ .../react-native-macos/react-native.config.js | 12 + samples/react-native-macos/src/App.tsx | 290 ++++++++++++++++++ .../src/Screens/ErrorsScreen.tsx | 226 ++++++++++++++ .../src/Screens/GesturesTracingScreen.tsx | 37 +++ .../src/Screens/ManualTrackerScreen.tsx | 151 +++++++++ .../src/Screens/PerformanceScreen.tsx | 105 +++++++ .../src/Screens/PerformanceTimingScreen.tsx | 53 ++++ .../src/Screens/PlaygroundScreen.tsx | 102 ++++++ .../src/Screens/ReduxScreen.tsx | 20 ++ .../src/Screens/TrackerScreen.tsx | 175 +++++++++++ .../src/assets/sentry-announcement.png | Bin 0 -> 20616 bytes .../src/components/Counter.tsx | 34 ++ .../src/components/SvgGraphic.tsx | 288 +++++++++++++++++ .../src/components/UserFeedbackModal.tsx | 109 +++++++ samples/react-native-macos/src/dsn.ts | 8 + samples/react-native-macos/src/reduxApp.ts | 45 +++ .../src/setScopeProperties.ts | 87 ++++++ samples/react-native-macos/src/utils.ts | 9 + samples/react-native-macos/tsconfig.json | 11 + samples/react-native/package.json | 1 - samples/react-native/src/App.tsx | 1 - yarn.lock | 44 ++- 62 files changed, 2386 insertions(+), 6 deletions(-) create mode 100644 samples/react-native-macos/.eslintrc.js create mode 100644 samples/react-native-macos/.gitignore create mode 100644 samples/react-native-macos/.prettierrc.js create mode 100644 samples/react-native-macos/.watchmanconfig create mode 100644 samples/react-native-macos/Gemfile create mode 100644 samples/react-native-macos/Gemfile.lock create mode 100644 samples/react-native-macos/_bundle/config create mode 100644 samples/react-native-macos/app.json create mode 100644 samples/react-native-macos/babel.config.js create mode 100644 samples/react-native-macos/index.js rename samples/{react-native => react-native-macos}/macos/.gitignore (100%) rename samples/{react-native => react-native-macos}/macos/.xcode.env (100%) rename samples/{react-native => react-native-macos}/macos/Podfile (100%) create mode 100644 samples/react-native-macos/macos/PrivacyInfo.xcprivacy rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/AppDelegate.h (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/AppDelegate.mm (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/128-mac.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/16-mac.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac 1.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac 1.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/512-mac.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/64-mac.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@1x.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Assets.xcassets/Contents.json (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Base.lproj/Main.storyboard (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/Info.plist (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/main.m (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample-macOS/sentry-react-native-sample.entitlements (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample.xcodeproj/project.pbxproj (99%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample.xcodeproj/xcshareddata/xcschemes/sentry-react-native-sample-macOS.xcscheme (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample.xcworkspace/contents.xcworkspacedata (100%) rename samples/{react-native => react-native-macos}/macos/sentry-react-native-sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (100%) create mode 100644 samples/react-native-macos/metro.config.js create mode 100644 samples/react-native-macos/package.json create mode 100644 samples/react-native-macos/react-native.config.js create mode 100644 samples/react-native-macos/src/App.tsx create mode 100644 samples/react-native-macos/src/Screens/ErrorsScreen.tsx create mode 100644 samples/react-native-macos/src/Screens/GesturesTracingScreen.tsx create mode 100644 samples/react-native-macos/src/Screens/ManualTrackerScreen.tsx create mode 100644 samples/react-native-macos/src/Screens/PerformanceScreen.tsx create mode 100644 samples/react-native-macos/src/Screens/PerformanceTimingScreen.tsx create mode 100644 samples/react-native-macos/src/Screens/PlaygroundScreen.tsx create mode 100644 samples/react-native-macos/src/Screens/ReduxScreen.tsx create mode 100644 samples/react-native-macos/src/Screens/TrackerScreen.tsx create mode 100644 samples/react-native-macos/src/assets/sentry-announcement.png create mode 100644 samples/react-native-macos/src/components/Counter.tsx create mode 100644 samples/react-native-macos/src/components/SvgGraphic.tsx create mode 100644 samples/react-native-macos/src/components/UserFeedbackModal.tsx create mode 100644 samples/react-native-macos/src/dsn.ts create mode 100644 samples/react-native-macos/src/reduxApp.ts create mode 100644 samples/react-native-macos/src/setScopeProperties.ts create mode 100644 samples/react-native-macos/src/utils.ts create mode 100644 samples/react-native-macos/tsconfig.json diff --git a/.github/workflows/sample-application.yml b/.github/workflows/sample-application.yml index af4cb7477d..8a821af7fc 100644 --- a/.github/workflows/sample-application.yml +++ b/.github/workflows/sample-application.yml @@ -145,7 +145,7 @@ jobs: - name: Build macOS App if: ${{ matrix.platform == 'macos' }} - working-directory: samples/react-native/macos + working-directory: samples/react-native-macos run: | [[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug' echo "Building $CONFIG" diff --git a/package.json b/package.json index cd62d29748..a6c34b35e4 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "dev-packages/e2e-tests", "dev-packages/type-check", "samples/react-native", + "samples/react-native-macos", "samples/expo", "performance-tests/TestAppPlain", "performance-tests/TestAppSentry" diff --git a/samples/react-native-macos/.eslintrc.js b/samples/react-native-macos/.eslintrc.js new file mode 100644 index 0000000000..b84c804e8d --- /dev/null +++ b/samples/react-native-macos/.eslintrc.js @@ -0,0 +1,17 @@ +module.exports = { + root: true, + extends: '@react-native', + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + overrides: [ + { + files: ['*.ts', '*.tsx'], + rules: { + '@typescript-eslint/no-shadow': ['error'], + 'no-shadow': 'off', + 'no-undef': 'off', + quotes: [2, 'single', { avoidEscape: true }], + }, + }, + ], +}; diff --git a/samples/react-native-macos/.gitignore b/samples/react-native-macos/.gitignore new file mode 100644 index 0000000000..290d47e12c --- /dev/null +++ b/samples/react-native-macos/.gitignore @@ -0,0 +1,65 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +*.xcode.env.local + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml +*.hprof +.cxx/ +*.keystore +!debug.keystore + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output + +# Bundle artifact +*.jsbundle + +# Ruby / CocoaPods +/ios/Pods/ +/vendor/bundle/ + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +*.xcarchive diff --git a/samples/react-native-macos/.prettierrc.js b/samples/react-native-macos/.prettierrc.js new file mode 100644 index 0000000000..2ae7b381ed --- /dev/null +++ b/samples/react-native-macos/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: true, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/samples/react-native-macos/.watchmanconfig b/samples/react-native-macos/.watchmanconfig new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/samples/react-native-macos/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/samples/react-native-macos/Gemfile b/samples/react-native-macos/Gemfile new file mode 100644 index 0000000000..0d169634b6 --- /dev/null +++ b/samples/react-native-macos/Gemfile @@ -0,0 +1,8 @@ +source 'https://rubygems.org' + +# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version +ruby "3.3.0" + +gem 'cocoapods', '1.15.2' +gem 'activesupport', '>= 6.1.7.5', '< 7.1.0' +gem 'fastlane', '2.220.0' diff --git a/samples/react-native-macos/Gemfile.lock b/samples/react-native-macos/Gemfile.lock new file mode 100644 index 0000000000..40d4693c84 --- /dev/null +++ b/samples/react-native-macos/Gemfile.lock @@ -0,0 +1,284 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.6) + rexml + activesupport (7.0.8) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + artifactory (3.0.17) + atomos (0.1.3) + aws-eventstream (1.3.0) + aws-partitions (1.915.0) + aws-sdk-core (3.192.0) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.8) + jmespath (~> 1, >= 1.6.1) + aws-sdk-kms (1.79.0) + aws-sdk-core (~> 3, >= 3.191.0) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.147.0) + aws-sdk-core (~> 3, >= 3.192.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.8) + aws-sigv4 (1.8.0) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.4) + base64 (0.2.0) + claide (1.1.0) + cocoapods (1.15.2) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.15.2) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 2.1, < 3.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.6.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 2.3.0, < 3.0) + xcodeproj (>= 1.23.0, < 2.0) + cocoapods-core (1.15.2) + activesupport (>= 5.0, < 8) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (2.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored (1.2) + colored2 (3.1.2) + commander (4.6.0) + highline (~> 2.0.0) + concurrent-ruby (1.2.2) + declarative (0.0.20) + digest-crc (0.6.5) + rake (>= 12.0.0, < 14.0.0) + domain_name (0.6.20240107) + dotenv (2.8.1) + emoji_regex (3.2.3) + escape (0.0.4) + ethon (0.16.0) + ffi (>= 1.15.0) + excon (0.110.0) + faraday (1.10.3) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) + http-cookie (~> 1.0.0) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + faraday_middleware (1.2.0) + faraday (~> 1.0) + fastimage (2.3.1) + fastlane (2.220.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.8, < 3.0.0) + artifactory (~> 3.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.3, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored (~> 1.2) + commander (~> 4.6) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 4.0) + excon (>= 0.71.0, < 1.0.0) + faraday (~> 1.0) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 1.0) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-apis-androidpublisher_v3 (~> 0.3) + google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-env (>= 1.6.0, < 2.0.0) + google-cloud-storage (~> 1.31) + highline (~> 2.0) + http-cookie (~> 1.0.5) + json (< 3.0.0) + jwt (>= 2.1.0, < 3) + mini_magick (>= 4.9.4, < 5.0.0) + multipart-post (>= 2.0.0, < 3.0.0) + naturally (~> 2.2) + optparse (>= 0.1.1, < 1.0.0) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 2.0.0, < 3.0.0) + security (= 0.1.5) + simctl (~> 1.6.3) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (~> 3) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.13.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3, < 2.0.0) + ffi (1.16.3) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + google-apis-androidpublisher_v3 (0.54.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-core (0.11.3) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.16.2, < 2.a) + httpclient (>= 2.8.1, < 3.a) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.a) + rexml + google-apis-iamcredentials_v1 (0.17.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-playcustomapp_v1 (0.13.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-storage_v1 (0.31.0) + google-apis-core (>= 0.11.0, < 2.a) + google-cloud-core (1.7.0) + google-cloud-env (>= 1.0, < 3.a) + google-cloud-errors (~> 1.0) + google-cloud-env (1.6.0) + faraday (>= 0.17.3, < 3.0) + google-cloud-errors (1.4.0) + google-cloud-storage (1.47.0) + addressable (~> 2.8) + digest-crc (~> 0.4) + google-apis-iamcredentials_v1 (~> 0.1) + google-apis-storage_v1 (~> 0.31.0) + google-cloud-core (~> 1.6) + googleauth (>= 0.16.2, < 2.a) + mini_mime (~> 1.0) + googleauth (1.8.1) + faraday (>= 0.17.3, < 3.a) + jwt (>= 1.4, < 3.0) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (>= 0.16, < 2.a) + highline (2.0.3) + http-cookie (1.0.5) + domain_name (~> 0.5) + httpclient (2.8.3) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + jmespath (1.6.2) + json (2.7.1) + jwt (2.8.1) + base64 + mini_magick (4.12.0) + mini_mime (1.1.5) + minitest (5.20.0) + molinillo (0.8.0) + multi_json (1.15.0) + multipart-post (2.4.0) + nanaimo (0.3.0) + nap (1.1.0) + naturally (2.2.1) + netrc (0.11.0) + optparse (0.5.0) + os (1.1.4) + plist (3.7.1) + public_suffix (4.0.7) + rake (13.2.1) + representable (3.2.0) + declarative (< 0.1.0) + trailblazer-option (>= 0.1.1, < 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rexml (3.2.6) + rouge (2.0.7) + ruby-macho (2.5.1) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + security (0.1.5) + signet (0.19.0) + addressable (~> 2.8) + faraday (>= 0.17.5, < 3.a) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.10) + CFPropertyList + naturally + terminal-notifier (2.0.0) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + trailblazer-option (0.1.2) + tty-cursor (0.7.1) + tty-screen (0.8.2) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) + typhoeus (1.4.1) + ethon (>= 0.9.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + uber (0.1.0) + unicode-display_width (2.5.0) + word_wrap (1.0.0) + xcodeproj (1.24.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.1) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + arm64-darwin-22 + arm64-darwin-23 + x86_64-darwin-20 + +DEPENDENCIES + activesupport (>= 6.1.7.5, < 7.1.0) + cocoapods (= 1.15.2) + fastlane (= 2.220.0) + +RUBY VERSION + ruby 3.3.0p0 + +BUNDLED WITH + 2.4.20 diff --git a/samples/react-native-macos/_bundle/config b/samples/react-native-macos/_bundle/config new file mode 100644 index 0000000000..848943bb52 --- /dev/null +++ b/samples/react-native-macos/_bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/samples/react-native-macos/app.json b/samples/react-native-macos/app.json new file mode 100644 index 0000000000..7757eb3748 --- /dev/null +++ b/samples/react-native-macos/app.json @@ -0,0 +1,4 @@ +{ + "name": "sentry-react-native-sample", + "displayName": "Sentry RN" +} diff --git a/samples/react-native-macos/babel.config.js b/samples/react-native-macos/babel.config.js new file mode 100644 index 0000000000..02c7d135f0 --- /dev/null +++ b/samples/react-native-macos/babel.config.js @@ -0,0 +1,4 @@ +module.exports = { + presets: ['module:@react-native/babel-preset'], + plugins: ['react-native-reanimated/plugin'], +}; diff --git a/samples/react-native-macos/index.js b/samples/react-native-macos/index.js new file mode 100644 index 0000000000..e1dd8be539 --- /dev/null +++ b/samples/react-native-macos/index.js @@ -0,0 +1,10 @@ +/** + * @format + */ + +import { AppRegistry } from 'react-native'; + +import App from './src/App'; +import { name as appName } from './app.json'; + +AppRegistry.registerComponent(appName, () => App); diff --git a/samples/react-native/macos/.gitignore b/samples/react-native-macos/macos/.gitignore similarity index 100% rename from samples/react-native/macos/.gitignore rename to samples/react-native-macos/macos/.gitignore diff --git a/samples/react-native/macos/.xcode.env b/samples/react-native-macos/macos/.xcode.env similarity index 100% rename from samples/react-native/macos/.xcode.env rename to samples/react-native-macos/macos/.xcode.env diff --git a/samples/react-native/macos/Podfile b/samples/react-native-macos/macos/Podfile similarity index 100% rename from samples/react-native/macos/Podfile rename to samples/react-native-macos/macos/Podfile diff --git a/samples/react-native-macos/macos/PrivacyInfo.xcprivacy b/samples/react-native-macos/macos/PrivacyInfo.xcprivacy new file mode 100644 index 0000000000..41b8317f06 --- /dev/null +++ b/samples/react-native-macos/macos/PrivacyInfo.xcprivacy @@ -0,0 +1,37 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + NSPrivacyCollectedDataTypes + + NSPrivacyTracking + + + diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/AppDelegate.h b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/AppDelegate.h similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/AppDelegate.h rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/AppDelegate.h diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/AppDelegate.mm b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/AppDelegate.mm similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/AppDelegate.mm rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/AppDelegate.mm diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/128-mac.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/128-mac.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/128-mac.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/128-mac.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/16-mac.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/16-mac.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/16-mac.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/16-mac.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac 1.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac 1.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac 1.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac 1.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/256-mac.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac 1.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac 1.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac 1.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac 1.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/32-mac.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/512-mac.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/512-mac.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/512-mac.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/512-mac.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/64-mac.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/64-mac.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/64-mac.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/64-mac.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@1x.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@1x.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@1x.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@1x.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/Contents.json b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/Contents.json similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Assets.xcassets/Contents.json rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Assets.xcassets/Contents.json diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Base.lproj/Main.storyboard b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Base.lproj/Main.storyboard similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Base.lproj/Main.storyboard rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Base.lproj/Main.storyboard diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/Info.plist b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/Info.plist similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/Info.plist rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/Info.plist diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/main.m b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/main.m similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/main.m rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/main.m diff --git a/samples/react-native/macos/sentry-react-native-sample-macOS/sentry-react-native-sample.entitlements b/samples/react-native-macos/macos/sentry-react-native-sample-macOS/sentry-react-native-sample.entitlements similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample-macOS/sentry-react-native-sample.entitlements rename to samples/react-native-macos/macos/sentry-react-native-sample-macOS/sentry-react-native-sample.entitlements diff --git a/samples/react-native/macos/sentry-react-native-sample.xcodeproj/project.pbxproj b/samples/react-native-macos/macos/sentry-react-native-sample.xcodeproj/project.pbxproj similarity index 99% rename from samples/react-native/macos/sentry-react-native-sample.xcodeproj/project.pbxproj rename to samples/react-native-macos/macos/sentry-react-native-sample.xcodeproj/project.pbxproj index ce8e098075..bc5901f207 100644 --- a/samples/react-native/macos/sentry-react-native-sample.xcodeproj/project.pbxproj +++ b/samples/react-native-macos/macos/sentry-react-native-sample.xcodeproj/project.pbxproj @@ -478,7 +478,10 @@ ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "$(inherited)"; OTHER_CPLUSPLUSFLAGS = "$(inherited)"; - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = false; @@ -535,7 +538,10 @@ MTL_ENABLE_DEBUG_INFO = NO; OTHER_CFLAGS = "$(inherited)"; OTHER_CPLUSPLUSFLAGS = "$(inherited)"; - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = false; diff --git a/samples/react-native/macos/sentry-react-native-sample.xcodeproj/xcshareddata/xcschemes/sentry-react-native-sample-macOS.xcscheme b/samples/react-native-macos/macos/sentry-react-native-sample.xcodeproj/xcshareddata/xcschemes/sentry-react-native-sample-macOS.xcscheme similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample.xcodeproj/xcshareddata/xcschemes/sentry-react-native-sample-macOS.xcscheme rename to samples/react-native-macos/macos/sentry-react-native-sample.xcodeproj/xcshareddata/xcschemes/sentry-react-native-sample-macOS.xcscheme diff --git a/samples/react-native/macos/sentry-react-native-sample.xcworkspace/contents.xcworkspacedata b/samples/react-native-macos/macos/sentry-react-native-sample.xcworkspace/contents.xcworkspacedata similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample.xcworkspace/contents.xcworkspacedata rename to samples/react-native-macos/macos/sentry-react-native-sample.xcworkspace/contents.xcworkspacedata diff --git a/samples/react-native/macos/sentry-react-native-sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/samples/react-native-macos/macos/sentry-react-native-sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from samples/react-native/macos/sentry-react-native-sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to samples/react-native-macos/macos/sentry-react-native-sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/samples/react-native-macos/metro.config.js b/samples/react-native-macos/metro.config.js new file mode 100644 index 0000000000..f34d60cc69 --- /dev/null +++ b/samples/react-native-macos/metro.config.js @@ -0,0 +1,70 @@ +const path = require('path'); +const { withSentryConfig } = require('@sentry/react-native/metro'); +const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); +const exclusionList = require('metro-config/src/defaults/exclusionList'); + +const projectRoot = __dirname; +const monorepoRoot = path.resolve(projectRoot, '../..'); + +// Only list the packages within your monorepo that your app uses. No need to add anything else. +// If your monorepo tooling can give you the list of monorepo workspaces linked +// in your app workspace, you can automate this list instead of hardcoding them. +const monorepoPackages = { + '@sentry/react-native': path.resolve(monorepoRoot, 'packages/core'), +}; + +/** + * Metro configuration + * https://facebook.github.io/metro/docs/configuration + * + * @type {import('metro-config').MetroConfig} + */ +const config = { + projectRoot: __dirname, + // 1. Watch the local app directory, and only the shared packages (limiting the scope and speeding it up) + // Note how we change this from `monorepoRoot` to `projectRoot`. This is part of the optimization! + watchFolders: [projectRoot, ...Object.values(monorepoPackages)], + resolver: { + resolverMainFields: ['main', 'react-native'], + resolveRequest: (context, moduleName, platform) => { + if (moduleName.includes('promise/')) { + return context.resolveRequest( + { + ...context, + // Ensures the promise module is resolved from the sample's node_modules. + allowHaste: false, + disableHierarchicalLookup: true, + }, + moduleName, + platform, + ); + } + return context.resolveRequest(context, moduleName, platform); + }, + blockList: exclusionList([ + new RegExp('.*\\android\\.*'), // Required for Windows in order to run the Sample. + ...Object.values(monorepoPackages).map( + p => new RegExp(`${p}/node_modules/react-native/.*`), + ), + ]), + // Add the monorepo workspaces as `extraNodeModules` to Metro. + // If your monorepo tooling creates workspace symlinks in the `node_modules` directory, + // you can either add symlink support to Metro or set the `extraNodeModules` to avoid the symlinks. + // See: https://metrobundler.dev/docs/configuration/#extranodemodules + extraNodeModules: { + ...monorepoPackages, + 'react-native': path.resolve(projectRoot, 'node_modules/react-native'), + }, + nodeModulesPaths: [ + path.resolve(projectRoot, 'node_modules'), + ...Object.values(monorepoPackages).map(p => + path.resolve(p, 'node_modules'), + ), + ], + }, +}; + +const m = mergeConfig(getDefaultConfig(__dirname), config); +module.exports = withSentryConfig(m, { + annotateReactComponents: true, +}); diff --git a/samples/react-native-macos/package.json b/samples/react-native-macos/package.json new file mode 100644 index 0000000000..374547b378 --- /dev/null +++ b/samples/react-native-macos/package.json @@ -0,0 +1,62 @@ +{ + "name": "sentry-react-native-macos-sample", + "version": "6.0.0-beta.0", + "private": true, + "scripts": { + "start": "react-native start --experimental-debugger", + "lint": "yarn type-check && npx eslint . --ext .js,.jsx,.ts,.tsx", + "fix": "yarn type-check && npx eslint . --ext .js,.jsx,.ts,.tsx --fix", + "type-check": "tsc --noEmit", + "pod-install": "cd macos; RCT_NEW_ARCH_ENABLED=1 bundle exec pod install; cd ..", + "pod-install-production": "cd macos; PRODUCTION=1 RCT_NEW_ARCH_ENABLED=1 bundle exec pod install; cd ..", + "pod-install-legacy": "cd macos; bundle exec pod install; cd ..", + "pod-install-legacy-production": "cd macos; PRODUCTION=1 bundle exec pod install; cd ..", + "clean-macos": "cd macos; rm -rf Podfile.lock Pods build; cd ..", + "clean-watchman": "watchman watch-del-all", + "set-build-number": "npx react-native-version --skip-tag --never-amend --set-build", + "set-version": "npx react-native-version --skip-tag --never-amend" + }, + "dependencies": { + "@react-navigation/bottom-tabs": "^6.5.12", + "@react-navigation/native": "^6.1.9", + "@react-navigation/stack": "^6.3.20", + "@sentry/react": "8.30.0", + "@sentry/react-native": "6.0.0-beta.0", + "@sentry/types": "8.30.0", + "@sentry/utils": "8.30.0", + "delay": "^6.0.0", + "react": "18.2.0", + "react-native": "0.73.9", + "react-native-gesture-handler": "2.14.0", + "react-native-macos": "0.73.34", + "react-native-reanimated": "3.8.1", + "react-native-safe-area-context": "4.8.0", + "react-native-screens": "3.29.0", + "react-native-svg": "^15.3.0", + "react-native-vector-icons": "^10.0.3", + "react-redux": "^8.1.3", + "redux": "^4.2.1" + }, + "devDependencies": { + "@babel/core": "^7.22.5", + "@babel/preset-env": "^7.22.5", + "@babel/runtime": "^7.22.5", + "@react-native/babel-preset": "0.73.21", + "@react-native/eslint-config": "0.73.2", + "@react-native/metro-config": "0.73.5", + "@react-native/typescript-config": "0.73.1", + "@types/react": "^18.2.65", + "@types/react-native-vector-icons": "^6.4.18", + "@types/react-test-renderer": "^18.0.0", + "@typescript-eslint/eslint-plugin": "^5.37.0", + "@typescript-eslint/parser": "^5.37.0", + "babel-plugin-module-resolver": "^5.0.0", + "eslint": "^8.19.0", + "jest": "^29.6.3", + "prettier": "2.8.8", + "typescript": "5.0.4" + }, + "engines": { + "node": ">=18" + } +} diff --git a/samples/react-native-macos/react-native.config.js b/samples/react-native-macos/react-native.config.js new file mode 100644 index 0000000000..88a418678a --- /dev/null +++ b/samples/react-native-macos/react-native.config.js @@ -0,0 +1,12 @@ +// Without this config the codegen fails +// because it can find @sentry/react-native +// in the dependencies +const path = require('path'); + +module.exports = { + project: { + ios: { + automaticPodsInstallation: true, + }, + }, +}; diff --git a/samples/react-native-macos/src/App.tsx b/samples/react-native-macos/src/App.tsx new file mode 100644 index 0000000000..d274783d53 --- /dev/null +++ b/samples/react-native-macos/src/App.tsx @@ -0,0 +1,290 @@ +import React from 'react'; +import { + NavigationContainer, + NavigationContainerRef, +} from '@react-navigation/native'; +import { createStackNavigator } from '@react-navigation/stack'; +import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; +import Animated, { + Easing, + useAnimatedStyle, + useSharedValue, + withRepeat, + withTiming, +} from 'react-native-reanimated'; + +// Import the Sentry React Native SDK +import * as Sentry from '@sentry/react-native'; + +import { SENTRY_INTERNAL_DSN } from './dsn'; +import ErrorsScreen from './Screens/ErrorsScreen'; +import PerformanceScreen from './Screens/PerformanceScreen'; +import TrackerScreen from './Screens/TrackerScreen'; +import ManualTrackerScreen from './Screens/ManualTrackerScreen'; +import PerformanceTimingScreen from './Screens/PerformanceTimingScreen'; +import ReduxScreen from './Screens/ReduxScreen'; +import { Provider } from 'react-redux'; +import { store } from './reduxApp'; +import { GestureHandlerRootView } from 'react-native-gesture-handler'; +import GesturesTracingScreen from './Screens/GesturesTracingScreen'; +import { LogBox, Platform, StyleSheet, View } from 'react-native'; +import Ionicons from 'react-native-vector-icons/Ionicons'; +import PlaygroundScreen from './Screens/PlaygroundScreen'; +import { logWithoutTracing } from './utils'; +import { ErrorEvent } from '@sentry/types'; + +LogBox.ignoreAllLogs(); +const isMobileOs = Platform.OS === 'android' || Platform.OS === 'ios'; + +const reactNavigationIntegration = Sentry.reactNavigationIntegration({ + routeChangeTimeoutMs: 500, // How long it will wait for the route change to complete. Default is 1000ms + enableTimeToInitialDisplay: isMobileOs, + ignoreEmptyBackNavigationTransactions: true, +}); + +Sentry.init({ + // Replace the example DSN below with your own DSN: + dsn: SENTRY_INTERNAL_DSN, + debug: true, + environment: 'dev', + beforeSend: (event: ErrorEvent) => { + logWithoutTracing('Event beforeSend:', event.event_id); + return event; + }, + beforeSendTransaction(event) { + logWithoutTracing('Transaction beforeSend:', event.event_id); + return event; + }, + // This will be called with a boolean `didCallNativeInit` when the native SDK has been contacted. + onReady: ({ didCallNativeInit }) => { + logWithoutTracing( + 'onReady called with didCallNativeInit:', + didCallNativeInit, + ); + }, + enableUserInteractionTracing: true, + integrations(integrations) { + integrations.push( + reactNavigationIntegration, + Sentry.reactNativeTracingIntegration({ + // The time to wait in ms until the transaction will be finished, For testing, default is 1000 ms + idleTimeoutMs: 5_000, + }), + Sentry.httpClientIntegration({ + // These options are effective only in JS. + // This array can contain tuples of `[begin, end]` (both inclusive), + // Single status codes, or a combinations of both. + // default: [[500, 599]] + failedRequestStatusCodes: [[400, 599]], + // This array can contain Regexes or strings, or combinations of both. + // default: [/.*/] + failedRequestTargets: [/.*/], + }), + Sentry.mobileReplayIntegration({ + maskAllImages: true, + maskAllVectors: true, + // maskAllText: false, + }), + Sentry.appStartIntegration({ + standalone: false, + }), + ); + return integrations.filter(i => i.name !== 'Dedupe'); + }, + enableAutoSessionTracking: true, + // For testing, session close when 5 seconds (instead of the default 30) in the background. + sessionTrackingIntervalMillis: 30000, + // This will capture ALL TRACES and likely use up all your quota + enableTracing: true, + tracesSampleRate: 1.0, + tracePropagationTargets: ['localhost', /^\//, /^https:\/\//, /^http:\/\//], + attachStacktrace: true, + // Attach screenshots to events. + attachScreenshot: true, + // Attach view hierarchy to events. + attachViewHierarchy: true, + // Enables capture failed requests in JS and native. + enableCaptureFailedRequests: true, + // Sets the `release` and `dist` on Sentry events. Make sure this matches EXACTLY with the values on your sourcemaps + // otherwise they will not work. + // release: 'myapp@1.2.3+1', + // dist: `1`, + profilesSampleRate: 1.0, + _experiments: { + // replaysSessionSampleRate: 1.0, + replaysOnErrorSampleRate: 1.0, + }, + spotlight: true, + // This should be disabled when manually initializing the native SDK + // Note that options from JS are not passed to the native SDKs when initialized manually + autoInitializeNativeSdk: true, +}); + +const Stack = createStackNavigator(); +const Tab = createBottomTabNavigator(); + +const TabOneStack = Sentry.withProfiler( + () => { + return ( + + + + + + + + ); + }, + { name: 'ErrorsTab' }, +); + +const TabTwoStack = Sentry.withProfiler( + () => { + return ( + + + + + + + + + + + + + ); + }, + { name: 'PerformanceTab' }, +); + +function BottomTabs() { + const navigation = React.useRef>(null); + + return ( + { + reactNavigationIntegration.registerNavigationContainer(navigation); + }}> + + ( + + ), + }} + /> + ( + + ), + }} + /> + ( + + ), + }} + /> + + + + ); +} + +function RunningIndicator() { + if (Platform.OS !== 'android' && Platform.OS !== 'ios') { + return null; + } + + return ; +} + +function RotatingBox() { + const sv = useSharedValue(0); + + React.useEffect(() => { + sv.value = withRepeat( + withTiming(360, { + duration: 1_000_000, + easing: Easing.linear, + }), + -1, + ); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + const animatedStyle = useAnimatedStyle(() => ({ + transform: [{ rotate: `${sv.value * 360}deg` }], + })); + + return ( + + + + ); +} + +const styles = StyleSheet.create({ + wrapper: { + flex: 1, + }, + container: { + position: 'absolute', + left: 30, + top: 30, + }, + box: { + height: 50, + width: 50, + backgroundColor: '#b58df1', + borderRadius: 5, + }, +}); + +export default Sentry.wrap(BottomTabs); diff --git a/samples/react-native-macos/src/Screens/ErrorsScreen.tsx b/samples/react-native-macos/src/Screens/ErrorsScreen.tsx new file mode 100644 index 0000000000..003c19b9d1 --- /dev/null +++ b/samples/react-native-macos/src/Screens/ErrorsScreen.tsx @@ -0,0 +1,226 @@ +import React from 'react'; +import { + StatusBar, + ScrollView, + Text, + Button as NativeButton, + View, + ButtonProps, + StyleSheet, +} from 'react-native'; + +import * as Sentry from '@sentry/react-native'; + +import { setScopeProperties } from '../setScopeProperties'; +import { StackNavigationProp } from '@react-navigation/stack'; +import { UserFeedbackModal } from '../components/UserFeedbackModal'; +import { FallbackRender } from '@sentry/react'; +import { timestampInSeconds } from '@sentry/utils'; + +interface Props { + navigation: StackNavigationProp; +} + +const ErrorsScreen = (_props: Props) => { + const [componentMountStartTimestamp] = React.useState(() => { + return timestampInSeconds(); + }); + + React.useEffect(() => { + if (componentMountStartTimestamp) { + // Distributions help you get the most insights from your data by allowing you to obtain aggregations such as p90, min, max, and avg. + Sentry.metrics.distribution( + 'home_mount_time', + timestampInSeconds() - componentMountStartTimestamp, + { + unit: 'seconds', + }, + ); + } + // We only want this to run once. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + // Show bad code inside error boundary to trigger it. + const [showBadCode, setShowBadCode] = React.useState(false); + const [isFeedbackVisible, setFeedbackVisible] = React.useState(false); + + const errorBoundaryFallback: FallbackRender = ({ eventId }) => ( + Error boundary caught with event id: {eventId} + ); + + return ( + <> + + +