├── sample ├── .watchmanconfig ├── .gitattributes ├── app.json ├── .eslintrc.js ├── android │ ├── app │ │ ├── .settings │ │ │ └── org.eclipse.buildship.core.prefs │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── java │ │ │ │ │ └── io │ │ │ │ │ │ └── sentry │ │ │ │ │ │ └── sample │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ │ └── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ └── io │ │ │ │ └── sentry │ │ │ │ └── sample │ │ │ │ └── ReactNativeFlipper.java │ │ ├── debug.keystore │ │ ├── .classpath │ │ ├── proguard-rules.pro │ │ ├── build_defs.bzl │ │ ├── .project │ │ └── _BUCK │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── sentry.properties │ ├── settings.gradle │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── .project │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── sample │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── AppDelegate.m │ │ ├── Info.plist │ │ └── Base.lproj │ │ │ └── LaunchScreen.xib │ ├── sentry.properties │ ├── sample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── sampleTests │ │ ├── Info.plist │ │ └── sampleTests.m │ ├── sample-tvOSTests │ │ └── Info.plist │ ├── Podfile │ ├── sample-tvOS │ │ └── Info.plist │ └── sample.xcodeproj │ │ └── xcshareddata │ │ └── xcschemes │ │ ├── sample.xcscheme │ │ └── sample-tvOS.xcscheme ├── jest.config.js ├── src │ ├── assets │ │ └── sentry-logo.png │ ├── dsn.ts │ ├── screens │ │ ├── ReduxScreen.tsx │ │ ├── PerformanceTimingScreen.tsx │ │ ├── EndToEndTestsScreen.tsx │ │ ├── TrackerScreen.tsx │ │ └── ManualTrackerScreen.tsx │ ├── reduxApp.ts │ ├── components │ │ └── Counter.tsx │ └── App.tsx ├── .buckconfig ├── .prettierrc.js ├── index.js ├── babel.config.js ├── tsconfig.json ├── utils │ ├── getTestProps.ts │ └── fetchEvent.ts ├── .gitignore ├── package.json ├── metro.config.js ├── .flowconfig └── test │ └── e2e.test.ts ├── .github ├── CODEOWNERS ├── censor.yml ├── release.yml ├── release-drafter.yml ├── workflows │ ├── danger.yml │ ├── release.yml │ ├── codeql-analysis.yml │ ├── buildandtest.yml │ └── e2e.yml ├── pull_request_template.md ├── ISSUE_TEMPLATE.md └── dependabot.yml ├── assets ├── raven.png ├── enriched.png ├── mixed-stacktrace.png └── additional-device.png ├── babel.config.js ├── src └── js │ ├── version.ts │ ├── integrations │ ├── index.ts │ ├── devicecontext.ts │ ├── release.ts │ ├── reactnativeerrorhandlers.ts │ └── debugsymbolicator.ts │ ├── tracing │ ├── index.ts │ ├── types.ts │ ├── utils.ts │ ├── routingInstrumentation.ts │ └── reactnativetracing.ts │ ├── transports │ └── native.ts │ ├── client.ts │ ├── scope.ts │ ├── options.ts │ ├── index.ts │ ├── backend.ts │ ├── sdk.ts │ └── touchevents.tsx ├── .eslintignore ├── ios ├── RNSentry.h └── RNSentry.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── .npmignore ├── .vscode ├── extensions.json ├── settings.json └── launch.json ├── .craft.yml ├── tsconfig.json ├── scripts ├── craft-pre-release.sh └── version-bump.js ├── tsconfig.build.json ├── android ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── io │ │ └── sentry │ │ └── react │ │ └── RNSentryPackage.java ├── build.gradle └── .gitignore ├── react-native.config.js ├── .snyk ├── test ├── transports │ └── native.test.ts ├── sdk.test.ts ├── integrations │ └── release.test.ts ├── backend.test.ts └── touchevents.test.tsx ├── RNSentry.podspec ├── .gitignore ├── LICENSE.md ├── CONTRIBUTING.md ├── .eslintrc.js ├── dangerfile.js ├── package.json └── README.md /sample/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /sample/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @hazat @jennmueng 2 | -------------------------------------------------------------------------------- /.github/censor.yml: -------------------------------------------------------------------------------- 1 | _extends: sentry-probot 2 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | store: zeus 2 | targets: 3 | - github 4 | - npm 5 | -------------------------------------------------------------------------------- /sample/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "displayName": "sample" 4 | } -------------------------------------------------------------------------------- /assets/raven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/assets/raven.png -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["module:metro-react-native-babel-preset"], 3 | }; 4 | -------------------------------------------------------------------------------- /assets/enriched.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/assets/enriched.png -------------------------------------------------------------------------------- /sample/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | template: | 2 | ## What Changed 3 | 4 | $CHANGES 5 | 6 | We'd love to get feedback. 7 | -------------------------------------------------------------------------------- /assets/mixed-stacktrace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/assets/mixed-stacktrace.png -------------------------------------------------------------------------------- /sample/android/app/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir=.. 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /src/js/version.ts: -------------------------------------------------------------------------------- 1 | export const SDK_NAME = "sentry.javascript.react-native"; 2 | export const SDK_VERSION = "2.5.0-beta.1"; 3 | -------------------------------------------------------------------------------- /assets/additional-device.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/assets/additional-device.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | sample 3 | 4 | -------------------------------------------------------------------------------- /sample/ios/sample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # Ignore build generated dir 2 | dist 3 | 4 | # Ignore sample folder 5 | sample 6 | 7 | # Ignore dangerfile 8 | dangerfile.js -------------------------------------------------------------------------------- /sample/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/debug.keystore -------------------------------------------------------------------------------- /sample/jest.config.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | 3 | module.exports = { 4 | verbose: true, 5 | preset: 'react-native', 6 | }; 7 | -------------------------------------------------------------------------------- /sample/src/assets/sentry-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/src/assets/sentry-logo.png -------------------------------------------------------------------------------- /sample/src/dsn.ts: -------------------------------------------------------------------------------- 1 | export const SENTRY_INTERNAL_DSN = 2 | 'https://d870ad989e7046a8b9715a57f59b23b5@o447951.ingest.sentry.io/5428561'; 3 | -------------------------------------------------------------------------------- /sample/ios/sentry.properties: -------------------------------------------------------------------------------- 1 | defaults.url=https://sentry.io/ 2 | defaults.org=sentry-test 3 | defaults.project=react-native 4 | #auth.token= 5 | -------------------------------------------------------------------------------- /sample/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /sample/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /sample/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/android/sentry.properties: -------------------------------------------------------------------------------- 1 | defaults.url=https://sentry.io/ 2 | defaults.org=sentry-test 3 | defaults.project=react-native 4 | #auth.token= 5 | cli.executable=sentry-cli 6 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/sentry-react-native/trunk/sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ios/RNSentry.h: -------------------------------------------------------------------------------- 1 | #if __has_include() 2 | #import 3 | #else 4 | #import "RCTBridge.h" 5 | #endif 6 | 7 | @interface RNSentry : NSObject 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /ios/RNSentry.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | 3 | # Included to the final package 4 | !LICENSE.md 5 | !CHANGELOG.md 6 | !README.md 7 | !/dist/**/* 8 | !RNSentry.podspec 9 | !sentry.gradle 10 | !react-native.config.js 11 | !/ios/**/* 12 | !/android/**/* 13 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"] 5 | } 6 | -------------------------------------------------------------------------------- /src/js/integrations/index.ts: -------------------------------------------------------------------------------- 1 | export { DebugSymbolicator } from "./debugsymbolicator"; 2 | export { DeviceContext } from "./devicecontext"; 3 | export { ReactNativeErrorHandlers } from "./reactnativeerrorhandlers"; 4 | export { Release } from "./release"; 5 | -------------------------------------------------------------------------------- /sample/ios/sample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /sample/ios/sample/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /.craft.yml: -------------------------------------------------------------------------------- 1 | minVersion: 0.23.1 2 | changelogPolicy: simple 3 | preReleaseCommand: bash scripts/craft-pre-release.sh 4 | targets: 5 | - name: npm 6 | - name: github 7 | - name: registry 8 | sdks: 9 | npm:@sentry/react-native: 10 | includeNames: /none/ 11 | -------------------------------------------------------------------------------- /sample/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import 'react-native-gesture-handler'; 7 | 8 | import App from './src/App'; 9 | import {name as appName} from './app.json'; 10 | 11 | AppRegistry.registerComponent(appName, () => App); 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["src/js/*.ts", "src/js/*.tsx", "test/**/*.ts", "test/**/*.tsx"], 4 | "exclude": ["dist"], 5 | "compilerOptions": { 6 | "rootDir": ".", 7 | "jsx": "react-native", 8 | "types": ["jest"] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sample/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | plugins: [ 4 | [ 5 | 'module-resolver', 6 | { 7 | alias: { 8 | '@sentry/react-native': '../dist/js', 9 | }, 10 | }, 11 | ], 12 | ], 13 | }; 14 | -------------------------------------------------------------------------------- /sample/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "jsx": "react-native", 5 | "resolveJsonModule": true, 6 | "esModuleInterop": true, 7 | "paths": { 8 | "@sentry/react-native": ["../"] 9 | } 10 | }, 11 | "exclude": ["**/node_modules/*"] 12 | } 13 | -------------------------------------------------------------------------------- /sample/ios/sample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample/ios/sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /ios/RNSentry.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'sample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | 5 | include ':sentry_react-native' 6 | project(':sentry_react-native').projectDir = new File(rootProject.projectDir, '../../android') 7 | 8 | -------------------------------------------------------------------------------- /scripts/craft-pre-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eux 3 | # Move to the project root 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | cd $SCRIPT_DIR/.. 6 | OLD_VERSION="${1}" 7 | NEW_VERSION="${2}" 8 | # Do not tag and commit changes made by "npm version" 9 | export npm_config_git_tag_version=false 10 | npm version "${NEW_VERSION}" 11 | node scripts/version-bump.js 12 | -------------------------------------------------------------------------------- /sample/android/app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/@sentry/typescript/tsconfig.json", 3 | "include": ["src/js/*.ts"], 4 | "exclude": ["node_modules"], 5 | "compilerOptions": { 6 | "baseUrl": ".", 7 | "outDir": "dist", 8 | "rootDir": "src", 9 | "lib": ["es7"], 10 | "jsx": "react-native", 11 | "types": ["react-native"], 12 | "target": "es6", 13 | "module": "es6" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.github/workflows/danger.yml: -------------------------------------------------------------------------------- 1 | name: "Danger" 2 | on: 3 | pull_request: 4 | types: [opened, synchronize, reopened, edited, ready_for_review] 5 | 6 | jobs: 7 | build: 8 | name: Changelogs 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-node@v1 13 | - run: npx danger@10.5.2 ci 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | 17 | -------------------------------------------------------------------------------- /scripts/version-bump.js: -------------------------------------------------------------------------------- 1 | const replace = require("replace-in-file"); 2 | 3 | const pjson = require("../package.json"); 4 | 5 | replace({ 6 | files: ["src/js/version.ts"], 7 | from: /\d+\.\d+.\d+(?:-\w+(?:\.\w+)?)?/g, 8 | to: pjson.version, 9 | }) 10 | .then((changedFiles) => { 11 | console.log("Modified files:", changedFiles.join(", ")); 12 | }) 13 | .catch((error) => { 14 | console.error("Error occurred:", error); 15 | }); 16 | -------------------------------------------------------------------------------- /sample/src/screens/ReduxScreen.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {View, StyleSheet} from 'react-native'; 3 | 4 | import Counter from '../components/Counter'; 5 | 6 | const ReduxScreen = () => { 7 | return ( 8 | 9 | 10 | 11 | ); 12 | }; 13 | 14 | export default ReduxScreen; 15 | 16 | const styles = StyleSheet.create({ 17 | container: { 18 | padding: 20, 19 | }, 20 | }); 21 | -------------------------------------------------------------------------------- /sample/android/app/src/main/java/io/sentry/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.sentry.sample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is 9 | * used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "sample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /sample/android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir= 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /sample/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /src/js/tracing/index.ts: -------------------------------------------------------------------------------- 1 | export { ReactNativeTracing } from "./reactnativetracing"; 2 | 3 | export { 4 | RoutingInstrumentation, 5 | RoutingInstrumentationInstance, 6 | } from "./routingInstrumentation"; 7 | 8 | export { ReactNavigationV5Instrumentation } from "./reactnavigationv5"; 9 | export { ReactNavigationV4Instrumentation } from "./reactnavigationv4"; 10 | export { 11 | ReactNavigationCurrentRoute, 12 | ReactNavigationRoute, 13 | ReactNavigationTransactionContext, 14 | } from "./types"; 15 | -------------------------------------------------------------------------------- /sample/android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | sample 4 | Project android_ created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /react-native.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | dependency: { 3 | platforms: { 4 | ios: { 5 | sharedLibraries: ["libz"] 6 | }, 7 | android: { 8 | packageInstance: "new RNSentryPackage()" 9 | } 10 | }, 11 | hooks: { 12 | postlink: 13 | "node node_modules/@sentry/wizard/dist/bin.js -i reactNative -p ios android", 14 | postunlink: 15 | "node node_modules/@sentry/wizard/dist/bin.js -i reactNative -p ios android --uninstall" 16 | } 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /sample/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample/utils/getTestProps.ts: -------------------------------------------------------------------------------- 1 | import {Platform} from 'react-native'; 2 | 3 | /** 4 | * Each platform uses different test ids There is a bug in Appium where accessibilityLabel does not work on iOS so we need testID, 5 | * and testID does not work on Android so we need accessibilityLabel, 6 | * @param id 7 | * @param platform 8 | */ 9 | const getTestProps = (id: string) => 10 | Platform.OS === 'android' 11 | ? { 12 | accessibilityLabel: id, 13 | accessible: true, 14 | } 15 | : { 16 | testID: id, 17 | }; 18 | 19 | export {getTestProps}; 20 | -------------------------------------------------------------------------------- /src/js/tracing/types.ts: -------------------------------------------------------------------------------- 1 | import { TransactionContext } from "@sentry/types"; 2 | 3 | export interface ReactNavigationRoute { 4 | name: string; 5 | key: string; 6 | params: Record; 7 | } 8 | 9 | export interface ReactNavigationCurrentRoute extends ReactNavigationRoute { 10 | hasBeenSeen: boolean; 11 | } 12 | 13 | export interface ReactNavigationTransactionContext extends TransactionContext { 14 | tags: { 15 | "routing.instrumentation": string; 16 | "routing.route.name": string; 17 | }; 18 | data: { 19 | route: ReactNavigationCurrentRoute; 20 | previousRoute: ReactNavigationRoute | null; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /.snyk: -------------------------------------------------------------------------------- 1 | # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. 2 | version: v1.13.5 3 | ignore: {} 4 | # patches apply the minimum changes required to fix a vulnerability 5 | patch: 6 | SNYK-JS-LODASH-450202: 7 | - '@sentry/wizard > lodash': 8 | patched: '2019-07-08T05:10:31.334Z' 9 | - '@sentry/wizard > inquirer > lodash': 10 | patched: '2019-07-08T05:10:31.334Z' 11 | - snyk > snyk-config > lodash: 12 | patched: '2019-07-15T05:10:29.905Z' 13 | - snyk > snyk-nodejs-lockfile-parser > lodash: 14 | patched: '2019-07-15T05:10:29.905Z' 15 | - snyk > snyk-nuget-plugin > lodash: 16 | patched: '2019-07-15T05:10:29.905Z' 17 | -------------------------------------------------------------------------------- /test/transports/native.test.ts: -------------------------------------------------------------------------------- 1 | import { NativeTransport } from "../../src/js/transports/native"; 2 | 3 | jest.mock("../../src/js/wrapper", () => ({ 4 | NATIVE: { 5 | sendEvent: jest.fn(() => Promise.resolve({ status: 200 })), 6 | }, 7 | })); 8 | 9 | describe("NativeTransport", () => { 10 | test("call native sendEvent", async () => { 11 | // TODO: Remove this when we remove the fetch transport hack inside the native transport 12 | const transport = new NativeTransport({ 13 | dsn: 14 | "https://6890c2f6677340daa4804f8194804ea2@o19635.ingest.sentry.io/148053", 15 | }); 16 | await expect(transport.sendEvent({})).resolves.toEqual({ status: 200 }); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /sample/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /sample/android/app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | app 4 | Project app created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnType": true, 3 | "editor.formatOnPaste": false, 4 | "editor.formatOnSave": true, 5 | "editor.rulers": [120], 6 | "editor.tabSize": 2, 7 | "files.autoSave": "onWindowChange", 8 | "files.trimTrailingWhitespace": true, 9 | "files.insertFinalNewline": true, 10 | "search.exclude": { 11 | "**/node_modules/": true, 12 | "**/build/": true, 13 | "**/dist/": true 14 | }, 15 | "typescript.tsdk": "./node_modules/typescript/lib", 16 | "editor.codeActionsOnSave": { 17 | "source.fixAll": true 18 | }, 19 | "[json]": { 20 | "editor.formatOnType": false, 21 | "editor.formatOnPaste": false, 22 | "editor.formatOnSave": false 23 | }, 24 | "react-native-tools.projectRoot": "./sample" 25 | } 26 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## :loudspeaker: Type of change 2 | 3 | - [ ] Bugfix 4 | - [ ] New feature 5 | - [ ] Enhancement 6 | - [ ] Refactoring 7 | 8 | 9 | ## :scroll: Description 10 | 11 | 12 | 13 | ## :bulb: Motivation and Context 14 | 15 | 16 | 17 | 18 | ## :green_heart: How did you test it? 19 | 20 | 21 | ## :pencil: Checklist 22 | 23 | - [ ] I reviewed submitted code 24 | - [ ] I added tests to verify changes 25 | - [ ] All tests passing 26 | - [ ] No breaking changes 27 | 28 | ## :crystal_ball: Next steps 29 | -------------------------------------------------------------------------------- /sample/src/reduxApp.ts: -------------------------------------------------------------------------------- 1 | import {createStore} from 'redux'; 2 | import * as Sentry from '@sentry/react'; 3 | 4 | const initialState = { 5 | counter: 0, 6 | }; 7 | 8 | const reducer = (state = initialState, action) => { 9 | switch (action.type) { 10 | case 'COUNTER_INCREMENT': 11 | return { 12 | ...state, 13 | counter: state.counter + 1, 14 | }; 15 | case 'COUNTER_RESET': 16 | return { 17 | ...state, 18 | counter: 0, 19 | }; 20 | default: 21 | return state; 22 | } 23 | }; 24 | 25 | /* 26 | Example of how to use the Sentry redux enhancer packaged with @sentry/react: 27 | */ 28 | 29 | const sentryEnhancer = Sentry.createReduxEnhancer(); 30 | 31 | const store = createStore(reducer, sentryEnhancer); 32 | 33 | export {store}; 34 | -------------------------------------------------------------------------------- /src/js/tracing/utils.ts: -------------------------------------------------------------------------------- 1 | import { IdleTransaction, SpanStatus } from "@sentry/tracing"; 2 | 3 | /** 4 | * Converts from seconds to milliseconds 5 | * @param time time in seconds 6 | */ 7 | function secToMs(time: number): number { 8 | return time * 1000; 9 | } 10 | 11 | /** 12 | * 13 | */ 14 | export function adjustTransactionDuration( 15 | maxDuration: number, // in seconds 16 | transaction: IdleTransaction, 17 | endTimestamp: number 18 | ): void { 19 | const diff = endTimestamp - transaction.startTimestamp; 20 | const isOutdatedTransaction = 21 | endTimestamp && (diff > secToMs(maxDuration) || diff < 0); 22 | if (isOutdatedTransaction) { 23 | transaction.setStatus(SpanStatus.DeadlineExceeded); 24 | transaction.setTag("maxTransactionDurationExceeded", "true"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/ios/sample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /RNSentry.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | version = JSON.parse(File.read('package.json'))["version"] 3 | 4 | Pod::Spec.new do |s| 5 | s.name = 'RNSentry' 6 | s.version = version 7 | s.license = 'MIT' 8 | s.summary = 'Official Sentry SDK for react-native' 9 | s.author = 'Sentry' 10 | s.homepage = "https://github.com/getsentry/sentry-react-native" 11 | s.source = { :git => 'https://github.com/getsentry/sentry-react-native.git', :tag => "#{s.version}"} 12 | 13 | s.ios.deployment_target = "8.0" 14 | s.osx.deployment_target = "10.10" 15 | s.tvos.deployment_target = "9.0" 16 | 17 | s.preserve_paths = '*.js' 18 | 19 | s.dependency 'React-Core' 20 | s.dependency 'Sentry', '7.0.0' 21 | 22 | s.source_files = 'ios/RNSentry.{h,m}' 23 | s.public_header_files = 'ios/RNSentry.h' 24 | end 25 | -------------------------------------------------------------------------------- /sample/ios/sampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/ios/sample-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | io.sentry.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'sample' do 7 | config = use_native_modules! 8 | use_react_native!( 9 | :path => config["reactNativePath"], 10 | # to enable hermes on iOS, change `false` to `true` and then install pods 11 | :hermes_enabled => false 12 | ) 13 | 14 | pod 'RNSentry', :path => '../../RNSentry.podspec' 15 | 16 | target 'sampleTests' do 17 | inherit! :complete 18 | # Pods for testing 19 | end 20 | 21 | post_install do |installer| 22 | react_native_post_install(installer) 23 | end 24 | end 25 | 26 | target 'sample-tvOS' do 27 | # Pods for sample-tvOS 28 | 29 | target 'sample-tvOSTests' do 30 | inherit! :search_paths 31 | # Pods for testing 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /sample/src/components/Counter.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {View, Text, TouchableOpacity} from 'react-native'; 3 | import {useSelector, useDispatch} from 'react-redux'; 4 | 5 | const Counter = () => { 6 | const counter = useSelector((state) => state.counter); 7 | const dispatch = useDispatch(); 8 | 9 | return ( 10 | 11 | Count: 12 | {counter} 13 | 15 | dispatch({ 16 | type: 'COUNTER_INCREMENT', 17 | }) 18 | }> 19 | Increment 20 | 21 | 23 | dispatch({ 24 | type: 'COUNTER_RESET', 25 | }) 26 | }> 27 | Reset 28 | 29 | 30 | ); 31 | }; 32 | 33 | export default Counter; 34 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | def safeExtGet(prop, fallback) { 2 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 3 | } 4 | 5 | apply plugin: 'com.android.library' 6 | 7 | android { 8 | compileSdkVersion safeExtGet('compileSdkVersion', 28) 9 | buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') 10 | 11 | defaultConfig { 12 | minSdkVersion safeExtGet('minSdkVersion', 16) 13 | targetSdkVersion safeExtGet('targetSdkVersion', 28) 14 | versionCode 1 15 | versionName "1.0" 16 | ndk { 17 | abiFilters "x86", "armeabi-v7a", "x86_64", "arm64-v8a" 18 | } 19 | } 20 | 21 | compileOptions { 22 | sourceCompatibility JavaVersion.VERSION_1_8 23 | targetCompatibility JavaVersion.VERSION_1_8 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation 'com.facebook.react:react-native:+' 29 | api 'io.sentry:sentry-android:5.0.1' 30 | } 31 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | version: 6 | description: Version to release 7 | required: true 8 | force: 9 | description: Force a release even when there are release-blockers (optional) 10 | required: false 11 | 12 | jobs: 13 | job_release: 14 | runs-on: ubuntu-latest 15 | name: 'Release a new version' 16 | steps: 17 | - name: Check out current commit (${{ github.sha }}) 18 | uses: actions/checkout@v2 19 | with: 20 | token: ${{ secrets.GH_RELEASE_PAT }} 21 | fetch-depth: 0 22 | - name: Install Dependencies 23 | run: yarn install 24 | - name: Prepare release 25 | uses: getsentry/action-prepare-release@v1 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }} 28 | with: 29 | version: ${{ github.event.inputs.version }} 30 | force: ${{ github.event.inputs.force }} 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node 2 | node_modules 3 | *.log 4 | 5 | # Mac OS X 6 | .DS_Store 7 | 8 | # Xcode 9 | 10 | ## Build generated 11 | build/ 12 | DerivedData 13 | dist 14 | coverage 15 | 16 | ## Various settings 17 | *.pbxuser 18 | !default.pbxuser 19 | *.mode1v3 20 | !default.mode1v3 21 | *.mode2v3 22 | !default.mode2v3 23 | *.perspectivev3 24 | !default.perspectivev3 25 | xcuserdata 26 | 27 | ## Other 28 | *.xccheckout 29 | *.moved-aside 30 | *.xcuserstate 31 | *.xcscmblueprint 32 | 33 | ## Obj-C/Swift specific 34 | *.hmap 35 | *.ipa 36 | *.dSYM.zip 37 | 38 | ## Playgrounds 39 | timeline.xctimeline 40 | playground.xcworkspace 41 | 42 | # Swift Package Manager 43 | .build/ 44 | 45 | # Carthage 46 | Carthage/Build 47 | Carthage/Checkouts 48 | 49 | # CocoaPods 50 | **/Pods 51 | **/Podfile.lock 52 | 53 | # Fastlane 54 | appium/fastlane/test_output/ 55 | appium/fastlane/report.xml 56 | appium/.env 57 | appium/fastlane/README.md 58 | 59 | # Appium 60 | 61 | aws 62 | test_bundle.zip 63 | __pycache__ 64 | .cache 65 | wheelhouse 66 | 67 | # Android 68 | .idea/ 69 | -------------------------------------------------------------------------------- /src/js/transports/native.ts: -------------------------------------------------------------------------------- 1 | // import { Transports } from "@sentry/react"; 2 | import { Event, Response, Transport } from "@sentry/types"; 3 | import { PromiseBuffer, SentryError } from "@sentry/utils"; 4 | 5 | // import { Platform } from "react-native"; 6 | import { NATIVE } from "../wrapper"; 7 | 8 | /** Native Transport class implementation */ 9 | export class NativeTransport implements Transport { 10 | /** A simple buffer holding all requests. */ 11 | protected readonly _buffer: PromiseBuffer = new PromiseBuffer(30); 12 | 13 | /** 14 | * @inheritDoc 15 | */ 16 | public sendEvent(event: Event): PromiseLike { 17 | if (!this._buffer.isReady()) { 18 | return Promise.reject( 19 | new SentryError("Not adding Promise due to buffer limit reached.") 20 | ); 21 | } 22 | return this._buffer.add(NATIVE.sendEvent(event)); 23 | } 24 | 25 | /** 26 | * @inheritDoc 27 | */ 28 | public close(timeout?: number): PromiseLike { 29 | return this._buffer.drain(timeout); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /android/src/main/java/io/sentry/react/RNSentryPackage.java: -------------------------------------------------------------------------------- 1 | package io.sentry.react; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.bridge.NativeModule; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.uimanager.ViewManager; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | 13 | public class RNSentryPackage implements ReactPackage { 14 | public RNSentryPackage() { 15 | } 16 | 17 | @Override 18 | public List createNativeModules(ReactApplicationContext reactContext) { 19 | return Arrays.asList(new RNSentryModule(reactContext)); 20 | } 21 | 22 | public List> createJSModules() { 23 | return Collections.emptyList(); 24 | } 25 | 26 | @Override 27 | public List createViewManagers(ReactApplicationContext reactContext) { 28 | return Collections.emptyList(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /src/js/integrations/devicecontext.ts: -------------------------------------------------------------------------------- 1 | import { addGlobalEventProcessor, getCurrentHub } from "@sentry/core"; 2 | import { Event, Integration } from "@sentry/types"; 3 | import { logger } from "@sentry/utils"; 4 | 5 | import { NATIVE } from "../wrapper"; 6 | 7 | /** Load device context from native. */ 8 | export class DeviceContext implements Integration { 9 | /** 10 | * @inheritDoc 11 | */ 12 | public static id: string = "DeviceContext"; 13 | 14 | /** 15 | * @inheritDoc 16 | */ 17 | public name: string = DeviceContext.id; 18 | 19 | /** 20 | * @inheritDoc 21 | */ 22 | public setupOnce(): void { 23 | addGlobalEventProcessor(async (event: Event) => { 24 | const self = getCurrentHub().getIntegration(DeviceContext); 25 | if (!self) { 26 | return event; 27 | } 28 | 29 | try { 30 | const deviceContexts = await NATIVE.deviceContexts(); 31 | event.contexts = { ...deviceContexts, ...event.contexts }; 32 | } catch (e) { 33 | logger.log(`Failed to get device context from native: ${e}`); 34 | } 35 | 36 | return event; 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Sentry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sample/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.3" 6 | minSdkVersion = 21 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | } 10 | repositories { 11 | google() 12 | jcenter() 13 | } 14 | dependencies { 15 | classpath("com.android.tools.build:gradle:3.5.4") 16 | 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | jcenter() 36 | maven { url 'https://www.jitpack.io' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Attach to packager", 6 | "cwd": "${workspaceFolder}", 7 | "type": "reactnative", 8 | "request": "attach" 9 | }, 10 | { 11 | "type": "node", 12 | "request": "launch", 13 | "name": "Debug e2e:android", 14 | "cwd": "${workspaceFolder}/sample", 15 | "program": "./node_modules/jest/bin/jest", 16 | "args": [ 17 | "--runInBand", 18 | "--config=./jest.config.js" 19 | ], 20 | "env": { 21 | "PLATFORM": "android" 22 | }, 23 | "console": "integratedTerminal", 24 | "internalConsoleOptions": "neverOpen" 25 | }, 26 | { 27 | "type": "node", 28 | "request": "launch", 29 | "name": "Debug e2e:ios", 30 | "cwd": "${workspaceFolder}/sample", 31 | "program": "./node_modules/jest/bin/jest", 32 | "args": [ 33 | "--runInBand", 34 | "--config=./jest.config.js" 35 | ], 36 | "env": { 37 | "PLATFORM": "ios" 38 | }, 39 | "console": "integratedTerminal", 40 | "internalConsoleOptions": "neverOpen" 41 | }, 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **OS:** 2 | - [ ] Windows 3 | - [ ] MacOS 4 | - [ ] Linux 5 | 6 | **Platform:** 7 | - [ ] iOS 8 | - [ ] Android 9 | 10 | **SDK:** 11 | - [ ] `@sentry/react-native` (>= 1.0.0) 12 | - [ ] `react-native-sentry` (<= 0.43.2) 13 | 14 | **SDK version:** 0.0.0 15 | 16 | **`react-native` version:** 0.0.0 17 | 18 | **Are you using Expo?** 19 | - [ ] Yes 20 | - [ ] No 21 | 22 | **Are you using sentry.io or on-premise?** 23 | - [ ] sentry.io (SaaS) 24 | - [ ] on-premise 25 | 26 | **If you are using sentry.io, please post a link to your issue so we can take a look:** 27 | 28 | [Link to issue] 29 | 30 | **Configuration:** 31 | 32 | (`@sentry/react-native`) 33 | ``` 34 | Sentry.init({ 35 | dsn: 'https://...@sentry.io/...' 36 | // other options 37 | }); 38 | ``` 39 | 40 | or 41 | 42 | (`react-native-sentry`) 43 | ``` 44 | Sentry.config( 45 | 'https://...@sentry.io/...' 46 | // other options 47 | ).install(); 48 | ``` 49 | 50 | --- 51 | **I have following issue:** 52 | 53 | [Description] 54 | 55 | **Steps to reproduce:** 56 | - Step 1 57 | - Step 2 58 | 59 | **Actual result:** 60 | 61 | [Actual result] 62 | 63 | **Expected result:** 64 | 65 | [Expected result] 66 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This repository contains a sample project. It can be used to test the SDK as you develop it. 4 | 5 | # Requirements 6 | 7 | You need: 8 | 9 | - nodejs 8 or higher 10 | - yarn 1 or higher 11 | 12 | ## Building 13 | 14 | First install dependencies of the SDK (the root of the repository) 15 | This is only needed if dependencies are added/removed. 16 | 17 | ```sh 18 | yarn 19 | ``` 20 | 21 | Once deps are installed, you can build the project: 22 | 23 | ```sh 24 | yarn build 25 | 26 | # Or in watch mode, for development 27 | 28 | yarn build:watch 29 | ``` 30 | 31 | ## testing 32 | 33 | ```sh 34 | yarn test 35 | 36 | # Or the watcher when writing tests: 37 | yarn test:watch 38 | ``` 39 | 40 | ## Running the sample 41 | 42 | Now we can go into the sample project, install and build it: 43 | 44 | ```sh 45 | cd sample/ 46 | yarn 47 | 48 | # Build iOS 49 | cd ios 50 | pod install 51 | cd .. 52 | ``` 53 | 54 | You can optionally start the Metro bundler if you want to control where it runs: 55 | 56 | ```sh 57 | yarn start --reset-cache 58 | ``` 59 | 60 | Run the emulators: 61 | 62 | ```sh 63 | yarn react-native run-ios 64 | yarn react-native run-android 65 | ``` 66 | -------------------------------------------------------------------------------- /sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@react-native-community/masked-view": "^0.1.10", 4 | "@react-navigation/native": "^5.7.3", 5 | "@react-navigation/stack": "^5.9.0", 6 | "appium": "^1.20.2", 7 | "appium-doctor": "^1.15.4", 8 | "react": "17.0.1", 9 | "react-native": "0.64.0", 10 | "react-native-gesture-handler": "^1.10.3", 11 | "react-native-reanimated": "^1.13.0", 12 | "react-native-safe-area-context": "^3.1.4", 13 | "react-native-screens": "^2.10.1", 14 | "react-redux": "^7.2.1", 15 | "redux": "^4.0.5", 16 | "wd": "^1.14.0" 17 | }, 18 | "devDependencies": { 19 | "@babel/core": "^7.12.9", 20 | "@babel/runtime": "^7.12.5", 21 | "@react-native-community/eslint-config": "^2.0.0", 22 | "babel-jest": "^26.6.3", 23 | "babel-plugin-module-resolver": "^4.0.0", 24 | "dotenv": "^8.2.0", 25 | "eslint": "7.14.0", 26 | "jest": "^26.6.3", 27 | "metro-react-native-babel-preset": "^0.64.0", 28 | "react-test-renderer": "17.0.1" 29 | }, 30 | "name": "sample", 31 | "private": true, 32 | "scripts": { 33 | "android": "react-native run-android", 34 | "ios": "react-native run-ios", 35 | "lint": "eslint .", 36 | "start": "react-native start", 37 | "test": "jest" 38 | }, 39 | "version": "0.0.1" 40 | } 41 | -------------------------------------------------------------------------------- /src/js/client.ts: -------------------------------------------------------------------------------- 1 | import { BaseClient } from "@sentry/core"; 2 | 3 | import { ReactNativeBackend } from "./backend"; 4 | import { ReactNativeOptions } from "./options"; 5 | import { NATIVE } from "./wrapper"; 6 | 7 | /** 8 | * The Sentry React Native SDK Client. 9 | * 10 | * @see ReactNativeOptions for documentation on configuration options. 11 | * @see SentryClient for usage documentation. 12 | */ 13 | export class ReactNativeClient extends BaseClient< 14 | ReactNativeBackend, 15 | ReactNativeOptions 16 | > { 17 | /** 18 | * Creates a new React Native SDK instance. 19 | * @param options Configuration options for this SDK. 20 | */ 21 | public constructor(options: ReactNativeOptions) { 22 | super(ReactNativeBackend, options); 23 | } 24 | 25 | /** 26 | * If native client is available it will trigger a native crash. 27 | * Use this only for testing purposes. 28 | */ 29 | public nativeCrash(): void { 30 | this._getBackend().nativeCrash(); 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | public close(): PromiseLike { 37 | // As super.close() flushes queued events, we wait for that to finish before closing the native SDK. 38 | return super.close().then((result: boolean) => { 39 | return NATIVE.closeNativeSdk().then(() => result) as PromiseLike; 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sample/ios/sample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | @implementation AppDelegate 8 | 9 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 10 | { 11 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 12 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 13 | moduleName:@"sample" 14 | initialProperties:nil]; 15 | 16 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 17 | 18 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 19 | UIViewController *rootViewController = [UIViewController new]; 20 | rootViewController.view = rootView; 21 | self.window.rootViewController = rootViewController; 22 | [self.window makeKeyAndVisible]; 23 | return YES; 24 | } 25 | 26 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 27 | { 28 | #if DEBUG 29 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 30 | #else 31 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 32 | #endif 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | "react-native/react-native": true, 6 | }, 7 | extends: ["@sentry-internal/sdk"], 8 | plugins: ["@sentry-internal/sdk"], 9 | parserOptions: { 10 | project: "./tsconfig.json", 11 | }, 12 | settings: { 13 | version: "detect", // React version. "detect" automatically picks the version you have installed. 14 | }, 15 | overrides: [ 16 | { 17 | // Typescript Files 18 | files: ["*.ts", "*.tsx"], 19 | extends: ["plugin:react/recommended"], 20 | plugins: ["react", "react-native"], 21 | rules: { 22 | "@typescript-eslint/typedef": [ 23 | "error", 24 | { arrowParameter: false, variableDeclarationIgnoreFunction: true }, 25 | ], 26 | }, 27 | }, 28 | { 29 | // Test Files 30 | files: ["*.test.ts", "*.test.tsx", "*.test.js", "*.test.jsx"], 31 | rules: { 32 | "@typescript-eslint/no-var-requires": "off", 33 | }, 34 | }, 35 | { 36 | // Scripts 37 | files: ["scripts/*"], 38 | parserOptions: { 39 | ecmaVersion: 2015, 40 | }, 41 | rules: { 42 | "no-console": "off", 43 | }, 44 | }, 45 | ], 46 | rules: { 47 | // Bundle size isn't too much of an issue for React Native. 48 | "@sentry-internal/sdk/no-async-await": "off", 49 | }, 50 | }; 51 | -------------------------------------------------------------------------------- /sample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.37.0 29 | -------------------------------------------------------------------------------- /sample/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "io.sentry.sample", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "io.sentry.sample", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /sample/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | const path = require('path'); 9 | const blacklist = require('metro-config/src/defaults/blacklist'); 10 | const resolve = require('metro-resolver/src/resolve'); 11 | 12 | const parentDir = path.resolve(__dirname, '..'); 13 | 14 | module.exports = { 15 | projectRoot: __dirname, 16 | watchFolders: [path.resolve(__dirname, 'node_modules'), parentDir], 17 | resolver: { 18 | blacklistRE: blacklist([ 19 | new RegExp(`${parentDir}/node_modules/react-native/.*`), 20 | ]), 21 | extraNodeModules: new Proxy( 22 | { 23 | /* 24 | As the parent dir node_modules is blacklisted as you can see above. So it won't be able 25 | to find react-native to build the code from the parent folder, 26 | so we'll have to redirect it to use the react-native inside sample's node_modules. 27 | */ 28 | 'react-native': path.resolve(__dirname, 'node_modules/react-native'), 29 | }, 30 | { 31 | get: (target, name) => { 32 | if (target.hasOwnProperty(name)) { 33 | return target[name]; 34 | } 35 | return path.join(process.cwd(), `node_modules/${name}`); 36 | }, 37 | }, 38 | ), 39 | }, 40 | transformer: { 41 | getTransformOptions: async () => ({ 42 | transform: { 43 | experimentalImportSupport: false, 44 | inlineRequires: false, 45 | }, 46 | }), 47 | }, 48 | }; 49 | -------------------------------------------------------------------------------- /test/sdk.test.ts: -------------------------------------------------------------------------------- 1 | import { logger } from "@sentry/utils"; 2 | 3 | import { flush } from "../src/js/sdk"; 4 | 5 | jest.mock("@sentry/react", () => { 6 | const mockClient = { 7 | flush: jest.fn(() => Promise.resolve(true)), 8 | }; 9 | 10 | return { 11 | getCurrentHub: jest.fn(() => ({ 12 | getClient: jest.fn(() => mockClient), 13 | })), 14 | }; 15 | }); 16 | 17 | jest.spyOn(logger, "error"); 18 | 19 | import { getCurrentHub } from "@sentry/react"; 20 | 21 | describe("flush", () => { 22 | it("Calls flush on the client", async () => { 23 | const mockClient = getCurrentHub().getClient(); 24 | 25 | expect(mockClient).toBeTruthy(); 26 | 27 | if (mockClient) { 28 | const flushResult = await flush(); 29 | 30 | // eslint-disable-next-line @typescript-eslint/unbound-method 31 | expect(mockClient.flush).toBeCalled(); 32 | expect(flushResult).toBe(true); 33 | } 34 | }); 35 | 36 | it("Returns false if flush failed and logs error", async () => { 37 | const mockClient = getCurrentHub().getClient(); 38 | 39 | expect(mockClient).toBeTruthy(); 40 | if (mockClient) { 41 | mockClient.flush = jest.fn(() => Promise.reject()); 42 | 43 | const flushResult = await flush(); 44 | 45 | // eslint-disable-next-line @typescript-eslint/unbound-method 46 | expect(mockClient.flush).toBeCalled(); 47 | expect(flushResult).toBe(false); 48 | // eslint-disable-next-line @typescript-eslint/unbound-method 49 | expect(logger.error).toBeCalledWith("Failed to flush the event queue."); 50 | } 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /sample/ios/sample-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSExceptionDomains 28 | 29 | localhost 30 | 31 | NSExceptionAllowsInsecureHTTPLoads 32 | 33 | 34 | 35 | 36 | NSLocationWhenInUseUsageDescription 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /sample/utils/fetchEvent.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable: no-implicit-dependencies no-unsafe-any no-console 2 | import {Event} from '@sentry/types'; 3 | import fetch from 'node-fetch'; 4 | 5 | const domain = 'sentry.io'; 6 | const eventEndpoint = `/api/0/projects/sentry-sdks/sentry-react-native/events/`; 7 | 8 | interface ApiEvent extends Event { 9 | /** 10 | * The event returned from the API uses eventID 11 | */ 12 | eventID: string; 13 | } 14 | 15 | const RETRY_COUNT = 20; 16 | const RETRY_INTERVAL = 30000; 17 | 18 | const fetchEvent = async (eventId): Promise => { 19 | const url = `https://${domain}${eventEndpoint}${eventId}/`; 20 | 21 | const request = new fetch.Request(url, { 22 | headers: { 23 | Authorization: `Bearer ${process.env.SENTRY_AUTH_TOKEN}`, 24 | 'Content-Type': 'application/json', 25 | }, 26 | method: 'GET', 27 | }); 28 | 29 | let retries = 0; 30 | const retryer = (jsonResponse: any) => 31 | new Promise((resolve, reject) => { 32 | if (jsonResponse.detail === 'Event not found') { 33 | if (retries < RETRY_COUNT) { 34 | setTimeout(() => { 35 | retries++; 36 | console.log(`Retrying api request. Retry number: ${retries}`); 37 | resolve( 38 | fetch(request) 39 | .then((res) => res.json()) 40 | .then(retryer), 41 | ); 42 | }, RETRY_INTERVAL); 43 | } else { 44 | reject(new Error('Could not fetch event within retry limit.')); 45 | } 46 | } else { 47 | resolve(jsonResponse); 48 | } 49 | }); 50 | 51 | const json: ApiEvent = await fetch(request) 52 | // tslint:disable-next-line: no-unsafe-any 53 | .then((res) => res.json()) 54 | .then(retryer); 55 | 56 | return json; 57 | }; 58 | 59 | export {fetchEvent}; 60 | -------------------------------------------------------------------------------- /sample/ios/sample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | sample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 2.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /sample/src/screens/PerformanceTimingScreen.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {View, Text, StyleSheet} from 'react-native'; 3 | 4 | /** 5 | * A screen to test performance timing. 6 | * The `performance.now()` api has been found to return values with varying offsets. 7 | * As Sentry uses it for event and transaction timing, this screen is just to test the possible offsets and issues 8 | * that occur with it. 9 | */ 10 | const PerformanceTimingScreen = () => { 11 | const initialDate = React.useRef(0); 12 | const initialPerformance = React.useRef(0); 13 | 14 | const [performanceTime, setPerformanceTime] = React.useState(0); 15 | const [dateTime, setDateTime] = React.useState(0); 16 | 17 | React.useEffect(() => { 18 | // @ts-ignore 19 | if (typeof global.performance !== 'undefined') { 20 | initialDate.current = Date.now(); 21 | // @ts-ignore 22 | initialPerformance.current = global.performance.now(); 23 | 24 | const interval = setInterval(() => { 25 | // @ts-ignore 26 | setPerformanceTime(global.performance.now()); 27 | setDateTime(Date.now()); 28 | }, 1000); 29 | 30 | return () => clearInterval(interval); 31 | } 32 | }, []); 33 | 34 | const performanceElapsed = Math.floor( 35 | performanceTime - initialPerformance.current, 36 | ); 37 | const dateElapsed = Math.floor(dateTime - initialDate.current); 38 | 39 | return ( 40 | 41 | Performance Time: {performanceTime} 42 | Performance Elapsed: {performanceElapsed}ms 43 | Date Time: {dateTime} 44 | Date Elapsed: {dateElapsed}ms 45 | Difference: {performanceElapsed - dateElapsed}ms 46 | 47 | ); 48 | }; 49 | 50 | export default PerformanceTimingScreen; 51 | 52 | const styles = StyleSheet.create({ 53 | container: { 54 | flex: 1, 55 | }, 56 | }); 57 | -------------------------------------------------------------------------------- /sample/ios/sampleTests/sampleTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface sampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation sampleTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /src/js/scope.ts: -------------------------------------------------------------------------------- 1 | import { Scope } from "@sentry/hub"; 2 | import { Breadcrumb, User } from "@sentry/types"; 3 | 4 | import { NATIVE } from "./wrapper"; 5 | 6 | /** 7 | * Extends the scope methods to set scope on the Native SDKs 8 | */ 9 | export class ReactNativeScope extends Scope { 10 | /** 11 | * @inheritDoc 12 | */ 13 | public setUser(user: User | null): this { 14 | NATIVE.setUser(user); 15 | return super.setUser(user); 16 | } 17 | 18 | /** 19 | * @inheritDoc 20 | */ 21 | public setTag(key: string, value: string): this { 22 | NATIVE.setTag(key, value); 23 | return super.setTag(key, value); 24 | } 25 | 26 | /** 27 | * @inheritDoc 28 | */ 29 | public setTags(tags: { [key: string]: string }): this { 30 | // As native only has setTag, we just loop through each tag key. 31 | Object.keys(tags).forEach((key) => { 32 | NATIVE.setTag(key, tags[key]); 33 | }); 34 | return super.setTags(tags); 35 | } 36 | 37 | /** 38 | * @inheritDoc 39 | */ 40 | public setExtras(extras: { [key: string]: any }): this { 41 | Object.keys(extras).forEach((key) => { 42 | NATIVE.setExtra(key, extras[key]); 43 | }); 44 | return super.setExtras(extras); 45 | } 46 | 47 | /** 48 | * @inheritDoc 49 | */ 50 | public setExtra(key: string, extra: any): this { 51 | NATIVE.setExtra(key, extra); 52 | return super.setExtra(key, extra); 53 | } 54 | 55 | /** 56 | * @inheritDoc 57 | */ 58 | public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this { 59 | NATIVE.addBreadcrumb(breadcrumb); 60 | return super.addBreadcrumb(breadcrumb, maxBreadcrumbs); 61 | } 62 | 63 | /** 64 | * @inheritDoc 65 | */ 66 | public clearBreadcrumbs(): this { 67 | NATIVE.clearBreadcrumbs(); 68 | return super.clearBreadcrumbs(); 69 | } 70 | 71 | /** 72 | * @inheritDoc 73 | */ 74 | public setContext(key: string, context: { [key: string]: any } | null): this { 75 | NATIVE.setContext(key, context); 76 | return super.setContext(key, context); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/js/tracing/routingInstrumentation.ts: -------------------------------------------------------------------------------- 1 | import { Hub } from "@sentry/hub"; 2 | import { Transaction, TransactionContext } from "@sentry/types"; 3 | 4 | import { BeforeNavigate } from "./reactnativetracing"; 5 | 6 | export type TransactionCreator = ( 7 | context: TransactionContext 8 | ) => Transaction | undefined; 9 | 10 | export interface RoutingInstrumentationInstance { 11 | /** 12 | * Registers a listener that's called on every route change with a `TransactionContext`. 13 | * 14 | * Do not overwrite this unless you know what you are doing. 15 | * 16 | * @param listener A `RouteListener` 17 | * @param beforeNavigate BeforeNavigate 18 | */ 19 | registerRoutingInstrumentation( 20 | listener: TransactionCreator, 21 | beforeNavigate: BeforeNavigate 22 | ): void; 23 | /** 24 | * To be called when the route changes, BEFORE the new route mounts. 25 | * If this is called after a route mounts the child spans will not be correctly attached. 26 | * 27 | * @param context A `TransactionContext` used to initialize the transaction. 28 | */ 29 | onRouteWillChange(context: TransactionContext): Transaction | undefined; 30 | } 31 | 32 | /** 33 | * Base Routing Instrumentation. Can be used by users to manually instrument custom routers. 34 | * Pass this to the tracing integration, and call `onRouteWillChange` every time before a route changes. 35 | */ 36 | export class RoutingInstrumentation implements RoutingInstrumentationInstance { 37 | protected _getCurrentHub?: () => Hub; 38 | protected _beforeNavigate?: BeforeNavigate; 39 | 40 | private _tracingListener?: TransactionCreator; 41 | 42 | /** @inheritdoc */ 43 | registerRoutingInstrumentation( 44 | listener: TransactionCreator, 45 | beforeNavigate: BeforeNavigate 46 | ): void { 47 | this._tracingListener = listener; 48 | this._beforeNavigate = beforeNavigate; 49 | } 50 | 51 | /** @inheritdoc */ 52 | public onRouteWillChange( 53 | context: TransactionContext 54 | ): Transaction | undefined { 55 | return this._tracingListener?.(context); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/js/integrations/release.ts: -------------------------------------------------------------------------------- 1 | import { addGlobalEventProcessor, getCurrentHub } from "@sentry/core"; 2 | import { Event, Integration } from "@sentry/types"; 3 | 4 | import { NATIVE } from "../wrapper"; 5 | 6 | /** Release integration responsible to load release from file. */ 7 | export class Release implements Integration { 8 | /** 9 | * @inheritDoc 10 | */ 11 | public static id: string = "Release"; 12 | /** 13 | * @inheritDoc 14 | */ 15 | public name: string = Release.id; 16 | 17 | /** 18 | * @inheritDoc 19 | */ 20 | public setupOnce(): void { 21 | addGlobalEventProcessor(async (event: Event) => { 22 | const self = getCurrentHub().getIntegration(Release); 23 | if (!self) { 24 | return event; 25 | } 26 | 27 | const options = getCurrentHub().getClient()?.getOptions(); 28 | 29 | /* 30 | __sentry_release and __sentry_dist is set by the user with setRelease and setDist. If this is used then this is the strongest. 31 | Otherwise we check for the release and dist in the options passed on init, as this is stronger than the release/dist from the native build. 32 | */ 33 | if (typeof event.extra?.__sentry_release === "string") { 34 | event.release = `${event.extra.__sentry_release}`; 35 | } else if (typeof options?.release === "string") { 36 | event.release = options.release; 37 | } 38 | 39 | if (typeof event.extra?.__sentry_dist === "string") { 40 | event.dist = `${event.extra.__sentry_dist}`; 41 | } else if (typeof options?.dist === "string") { 42 | event.dist = options.dist; 43 | } 44 | 45 | if (event.release && event.dist) { 46 | return event; 47 | } 48 | 49 | try { 50 | const release = await NATIVE.fetchRelease(); 51 | if (release) { 52 | event.release = `${release.id}@${release.version}+${release.build}`; 53 | event.dist = `${release.build}`; 54 | } 55 | } catch (_Oo) { 56 | // Something went wrong, we just continue 57 | } 58 | 59 | return event; 60 | }); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /sample/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; These should not be required directly 12 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 13 | node_modules/warning/.* 14 | 15 | ; Flow doesn't support platforms 16 | .*/Libraries/Utilities/LoadingView.js 17 | 18 | [untyped] 19 | .*/node_modules/@react-native-community/cli/.*/.* 20 | 21 | [include] 22 | 23 | [libs] 24 | node_modules/react-native/interface.js 25 | node_modules/react-native/flow/ 26 | 27 | [options] 28 | emoji=true 29 | 30 | esproposal.optional_chaining=enable 31 | esproposal.nullish_coalescing=enable 32 | 33 | module.file_ext=.js 34 | module.file_ext=.json 35 | module.file_ext=.ios.js 36 | 37 | munge_underscores=true 38 | 39 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 40 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 41 | 42 | suppress_type=$FlowIssue 43 | suppress_type=$FlowFixMe 44 | suppress_type=$FlowFixMeProps 45 | suppress_type=$FlowFixMeState 46 | 47 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 48 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 49 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 50 | 51 | [lints] 52 | sketchy-null-number=warn 53 | sketchy-null-mixed=warn 54 | sketchy-number=warn 55 | untyped-type-import=warn 56 | nonstrict-import=warn 57 | deprecated-type=warn 58 | unsafe-getters-setters=warn 59 | inexact-spread=warn 60 | unnecessary-invariant=warn 61 | signature-verification-failure=warn 62 | deprecated-utility=error 63 | 64 | [strict] 65 | deprecated-type 66 | nonstrict-import 67 | sketchy-null 68 | unclear-type 69 | unsafe-getters-setters 70 | untyped-import 71 | untyped-type-import 72 | 73 | [version] 74 | ^0.122.0 75 | -------------------------------------------------------------------------------- /dangerfile.js: -------------------------------------------------------------------------------- 1 | const PR_NUMBER = danger.github.pr.number; 2 | const PR_URL = danger.github.pr.html_url; 3 | 4 | function getCleanTitle() { 5 | const title = danger.github.pr.title; 6 | return title.split(": ").slice(-1)[0].trim().replace(/\.+$/, ""); 7 | } 8 | 9 | function getChangelogDetails() { 10 | return ` 11 |
12 | Instructions and example for changelog 13 | 14 | Please add an entry to \`CHANGELOG.md\` to the "Unreleased" section under the following heading: 15 | 1. **feat**: For new user-visible functionality. 16 | 2. **fix**: For user-visible bug fixes. 17 | 3. **ref**: For features, refactors and bug fixes in internal operations. 18 | 19 | To the changelog entry, please add a link to this PR (consider a more descriptive message): 20 | 21 | \`\`\`md 22 | - ${getCleanTitle()}. (${PR_NUMBER}) 23 | \`\`\` 24 | 25 | If none of the above apply, you can opt out by adding _#skip-changelog_ to the PR description. 26 | 27 |
28 | `; 29 | } 30 | 31 | async function containsChangelog(path) { 32 | const contents = await danger.github.utils.fileContents(path); 33 | return contents.includes(PR_NUMBER); 34 | } 35 | 36 | async function checkChangelog() { 37 | const skipChangelog = 38 | danger.github && (danger.github.pr.body + "").includes("#skip-changelog"); 39 | const isBot = danger.github && danger.github.pr.user.type === "Bot"; 40 | 41 | if (skipChangelog || isBot) { 42 | return; 43 | } 44 | 45 | const hasChangelog = await containsChangelog("CHANGELOG.md"); 46 | 47 | if (!hasChangelog) { 48 | fail("Please consider adding a changelog entry for the next release."); 49 | markdown(getChangelogDetails()); 50 | } 51 | } 52 | 53 | async function checkIfFeature() { 54 | const title = danger.github.pr.title; 55 | if(title.startsWith('feat:')){ 56 | message('Do not forget to update Sentry-docs with your feature once the pull request gets approved.'); 57 | } 58 | 59 | } 60 | 61 | async function checkAll() { 62 | // See: https://spectrum.chat/danger/javascript/support-for-github-draft-prs~82948576-ce84-40e7-a043-7675e5bf5690 63 | const isDraft = danger.github.pr.mergeable_state === "draft"; 64 | 65 | if (isDraft) { 66 | return; 67 | } 68 | 69 | await checkIfFeature(); 70 | await checkChangelog(); 71 | } 72 | 73 | schedule(checkAll); 74 | -------------------------------------------------------------------------------- /src/js/options.ts: -------------------------------------------------------------------------------- 1 | import { BrowserOptions } from "@sentry/react"; 2 | 3 | /** 4 | * Configuration options for the Sentry ReactNative SDK. 5 | * @see ReactNativeFrontend for more information. 6 | */ 7 | 8 | export interface ReactNativeOptions extends BrowserOptions { 9 | /** 10 | * Enables native transport + device info + offline caching. 11 | * Be careful, disabling this also breaks automatic release setting. 12 | * This means you have to manage setting the release yourself. 13 | * Defaults to `true`. 14 | */ 15 | enableNative?: boolean; 16 | 17 | /** 18 | * Enables native crashHandling. This only works if `enableNative` is `true`. 19 | * Defaults to `true`. 20 | */ 21 | enableNativeCrashHandling?: boolean; 22 | 23 | /** 24 | * Initializes the native SDK on init. 25 | * Set this to `false` if you have an existing native SDK and don't want to re-initialize. 26 | * 27 | * NOTE: Be careful and only use this if you know what you are doing. 28 | * If you use this flag, make sure a native SDK is running before the JS Engine initializes or events might not be captured. 29 | * Also, make sure the DSN on both the React Native side and the native side are the same one. 30 | * We strongly recommend checking the documentation if you need to use this. 31 | * 32 | * @default true 33 | */ 34 | autoInitializeNativeSdk?: boolean; 35 | 36 | /** Maximum time to wait to drain the request queue, before the process is allowed to exit. */ 37 | shutdownTimeout?: number; 38 | 39 | /** Should the native nagger alert be shown or not. */ 40 | enableNativeNagger?: boolean; 41 | 42 | /** Should sessions be tracked to Sentry Health or not. */ 43 | enableAutoSessionTracking?: boolean; 44 | 45 | /** The interval to end a session if the App goes to the background. */ 46 | sessionTrackingIntervalMillis?: number; 47 | 48 | /** Enable scope sync from Java to NDK on Android */ 49 | enableNdkScopeSync?: boolean; 50 | 51 | /** When enabled, all the threads are automatically attached to all logged events on Android */ 52 | attachThreads?: boolean; 53 | 54 | /** 55 | * Callback that is called after the RN SDK on the JS Layer has made contact with the Native Layer. 56 | */ 57 | onReady?: (response: { 58 | /** `true` if the native SDK has been initialized, `false` otherwise. */ 59 | didCallNativeInit: boolean; 60 | }) => void; 61 | } 62 | -------------------------------------------------------------------------------- /sample/src/screens/EndToEndTestsScreen.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {ScrollView, Text} from 'react-native'; 3 | 4 | import * as Sentry from '@sentry/react-native'; 5 | 6 | import {getTestProps} from '../../utils/getTestProps'; 7 | import {SENTRY_INTERNAL_DSN} from '../dsn'; 8 | 9 | /** 10 | * This screen is for internal end-to-end testing purposes only. Do not use. 11 | * Not visible through the UI (no button to load it). 12 | */ 13 | const EndToEndTestsScreen = () => { 14 | const [eventId, setEventId] = React.useState(null); 15 | 16 | // !!! WARNING: Do not put Sentry.init inside React.useEffect like we do here. This is only for testing purposes. 17 | // We only do this to render the eventId onto the UI for end to end tests. 18 | React.useEffect(() => { 19 | Sentry.init({ 20 | dsn: SENTRY_INTERNAL_DSN, 21 | beforeSend: (e) => { 22 | setEventId(e.event_id); 23 | return e; 24 | }, 25 | }); 26 | }, []); 27 | 28 | return ( 29 | 30 | {eventId} 31 | setEventId('')}> 32 | Clear Event Id 33 | 34 | { 37 | Sentry.captureMessage('React Native Test Message'); 38 | }}> 39 | captureMessage 40 | 41 | { 44 | Sentry.captureException(new Error('captureException test')); 45 | }}> 46 | captureException 47 | 48 | { 51 | throw new Error('throw new error test'); 52 | }}> 53 | throw new Error 54 | 55 | { 57 | new Promise(() => { 58 | throw new Error('Unhandled Promise Rejection'); 59 | }); 60 | }} 61 | {...getTestProps('unhandledPromiseRejection')}> 62 | Unhandled Promise Rejection 63 | 64 | { 67 | Sentry.close(); 68 | }}> 69 | close 70 | 71 | { 73 | Sentry.nativeCrash(); 74 | }}> 75 | nativeCrash 76 | 77 | 78 | ); 79 | }; 80 | 81 | export default EndToEndTestsScreen; 82 | -------------------------------------------------------------------------------- /src/js/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | Breadcrumb, 3 | Request, 4 | SdkInfo, 5 | Event, 6 | Exception, 7 | Response, 8 | Severity, 9 | StackFrame, 10 | Stacktrace, 11 | Status, 12 | Thread, 13 | User, 14 | } from "@sentry/types"; 15 | 16 | import { addGlobalEventProcessor } from "@sentry/core"; 17 | export { 18 | addGlobalEventProcessor, 19 | addBreadcrumb, 20 | captureException, 21 | captureEvent, 22 | captureMessage, 23 | configureScope, 24 | getHubFromCarrier, 25 | getCurrentHub, 26 | Hub, 27 | Scope, 28 | setContext, 29 | setExtra, 30 | setExtras, 31 | setTag, 32 | setTags, 33 | setUser, 34 | startTransaction, 35 | withScope, 36 | } from "@sentry/core"; 37 | 38 | // We need to import it so we patch the hub with global functions 39 | // aka. this has side effects 40 | import "@sentry/tracing"; 41 | 42 | export { 43 | Integrations as BrowserIntegrations, 44 | ErrorBoundary, 45 | withErrorBoundary, 46 | createReduxEnhancer, 47 | Profiler, 48 | useProfiler, 49 | withProfiler, 50 | } from "@sentry/react"; 51 | 52 | import * as Integrations from "./integrations"; 53 | import { SDK_NAME, SDK_VERSION } from "./version"; 54 | 55 | export { ReactNativeBackend } from "./backend"; 56 | export { ReactNativeOptions } from "./options"; 57 | export { ReactNativeClient } from "./client"; 58 | // eslint-disable-next-line deprecation/deprecation 59 | export { init, setDist, setRelease, nativeCrash, flush, close } from "./sdk"; 60 | export { TouchEventBoundary, withTouchEventBoundary } from "./touchevents"; 61 | 62 | export { 63 | ReactNativeTracing, 64 | ReactNavigationV4Instrumentation, 65 | ReactNavigationV5Instrumentation, 66 | RoutingInstrumentation, 67 | ReactNavigationTransactionContext, 68 | } from "./tracing"; 69 | 70 | /** 71 | * Adds the sdk info. Make sure this is called after @sentry/react's so this is the top-level SDK. 72 | */ 73 | function createReactNativeEventProcessor(): void { 74 | if (addGlobalEventProcessor) { 75 | addGlobalEventProcessor((event) => { 76 | event.platform = event.platform || "javascript"; 77 | event.sdk = { 78 | ...event.sdk, 79 | name: SDK_NAME, 80 | packages: [ 81 | ...((event.sdk && event.sdk.packages) || []), 82 | { 83 | name: "npm:@sentry/react-native", 84 | version: SDK_VERSION, 85 | }, 86 | ], 87 | version: SDK_VERSION, 88 | }; 89 | 90 | return event; 91 | }); 92 | } 93 | } 94 | 95 | createReactNativeEventProcessor(); 96 | 97 | export { Integrations, SDK_NAME, SDK_VERSION }; 98 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ trunk ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ trunk ] 20 | schedule: 21 | - cron: '27 16 * * 5' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | language: [ 'javascript' ] 32 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 33 | # Learn more: 34 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v2 39 | 40 | # Initializes the CodeQL tools for scanning. 41 | - name: Initialize CodeQL 42 | uses: github/codeql-action/init@v1 43 | with: 44 | languages: ${{ matrix.language }} 45 | # If you wish to specify custom queries, you can do so here or in a config file. 46 | # By default, queries listed here will override any specified in a config file. 47 | # Prefix the list here with "+" to use these queries and those in the config file. 48 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 49 | 50 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 51 | # If this step fails, then you should remove it and run the build manually (see below) 52 | - name: Autobuild 53 | uses: github/codeql-action/autobuild@v1 54 | 55 | # ℹ️ Command-line programs to run using the OS shell. 56 | # 📚 https://git.io/JvXDl 57 | 58 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 59 | # and modify them (or add more) to build your code if your project 60 | # uses a compiled language 61 | 62 | #- run: | 63 | # make bootstrap 64 | # make release 65 | 66 | - name: Perform CodeQL Analysis 67 | uses: github/codeql-action/analyze@v1 68 | -------------------------------------------------------------------------------- /sample/android/app/src/main/java/io/sentry/sample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package io.sentry.sample; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | 14 | import io.sentry.react.RNSentryPackage; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | packages.add(new RNSentryPackage()); 29 | return packages; 30 | } 31 | 32 | @Override 33 | protected String getJSMainModuleName() { 34 | return "index"; 35 | } 36 | }; 37 | 38 | @Override 39 | public ReactNativeHost getReactNativeHost() { 40 | return mReactNativeHost; 41 | } 42 | 43 | @Override 44 | public void onCreate() { 45 | super.onCreate(); 46 | SoLoader.init(this, /* native exopackage */ false); 47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 48 | } 49 | 50 | /** 51 | * Loads Flipper in React Native templates. Call this in the onCreate method 52 | * with something like initializeFlipper(this, 53 | * getReactNativeHost().getReactInstanceManager()); 54 | * 55 | * @param context 56 | * @param reactInstanceManager 57 | */ 58 | private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 59 | if (BuildConfig.DEBUG) { 60 | try { 61 | /* 62 | * We use reflection here to pick up the class that initializes Flipper, since 63 | * Flipper library is not available in release mode 64 | */ 65 | Class aClass = Class.forName("io.sentry.sample.ReactNativeFlipper"); 66 | aClass.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class).invoke(null, context, 67 | reactInstanceManager); 68 | } catch (ClassNotFoundException e) { 69 | e.printStackTrace(); 70 | } catch (NoSuchMethodException e) { 71 | e.printStackTrace(); 72 | } catch (IllegalAccessException e) { 73 | e.printStackTrace(); 74 | } catch (InvocationTargetException e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | open-pull-requests-limit: 10 8 | ignore: 9 | - dependency-name: "@sentry/core" 10 | versions: 11 | - 6.2.1 12 | - 6.2.2 13 | - 6.2.3 14 | - 6.2.5 15 | - 6.3.1 16 | - dependency-name: "@sentry/browser" 17 | versions: 18 | - 6.0.3 19 | - 6.1.0 20 | - 6.2.2 21 | - 6.2.3 22 | - 6.2.5 23 | - 6.3.1 24 | - dependency-name: "@sentry/tracing" 25 | versions: 26 | - 6.0.3 27 | - 6.1.0 28 | - 6.2.1 29 | - 6.2.2 30 | - 6.2.3 31 | - 6.2.5 32 | - 6.3.1 33 | - dependency-name: "@types/react-native" 34 | versions: 35 | - 0.63.48 36 | - 0.63.49 37 | - 0.63.50 38 | - 0.63.51 39 | - 0.64.0 40 | - 0.64.4 41 | - dependency-name: "@sentry/hub" 42 | versions: 43 | - 6.0.3 44 | - 6.1.0 45 | - 6.2.1 46 | - 6.2.2 47 | - 6.2.3 48 | - 6.3.1 49 | - dependency-name: "@sentry/types" 50 | versions: 51 | - 6.0.3 52 | - 6.1.0 53 | - 6.2.1 54 | - 6.2.2 55 | - 6.2.3 56 | - 6.3.1 57 | - dependency-name: eslint 58 | versions: 59 | - 7.19.0 60 | - 7.20.0 61 | - 7.21.0 62 | - 7.22.0 63 | - 7.23.0 64 | - 7.24.0 65 | - 7.25.0 66 | - dependency-name: "@sentry-internal/eslint-config-sdk" 67 | versions: 68 | - 6.0.3 69 | - 6.2.1 70 | - 6.2.2 71 | - 6.2.3 72 | - 6.3.1 73 | - dependency-name: "@sentry/utils" 74 | versions: 75 | - 6.1.0 76 | - 6.2.2 77 | - 6.2.3 78 | - 6.3.1 79 | - dependency-name: eslint-plugin-react 80 | versions: 81 | - 7.23.1 82 | - 7.23.2 83 | - dependency-name: "@sentry-internal/eslint-plugin-sdk" 84 | versions: 85 | - 6.0.3 86 | - 6.1.0 87 | - 6.2.1 88 | - 6.2.2 89 | - 6.2.3 90 | - 6.2.5 91 | - dependency-name: "@sentry/wizard" 92 | versions: 93 | - 1.2.3 94 | - dependency-name: "@sentry/integrations" 95 | versions: 96 | - 6.0.3 97 | - 6.1.0 98 | - 6.2.1 99 | - 6.2.2 100 | - 6.2.3 101 | - 6.2.5 102 | - dependency-name: "@types/jest" 103 | versions: 104 | - 26.0.21 105 | - 26.0.22 106 | - dependency-name: "@sentry/react" 107 | versions: 108 | - 6.0.3 109 | - 6.1.0 110 | - 6.2.3 111 | - dependency-name: "@types/react" 112 | versions: 113 | - 17.0.1 114 | - 17.0.2 115 | - 17.0.3 116 | - dependency-name: typescript 117 | versions: 118 | - 3.9.9 119 | - dependency-name: replace-in-file 120 | versions: 121 | - 6.2.0 122 | - package-ecosystem: gradle 123 | directory: "/android" 124 | schedule: 125 | interval: weekly 126 | open-pull-requests-limit: 10 127 | ignore: 128 | - dependency-name: io.sentry:sentry-android 129 | versions: 130 | - 4.2.0 131 | -------------------------------------------------------------------------------- /test/integrations/release.test.ts: -------------------------------------------------------------------------------- 1 | import { addGlobalEventProcessor, getCurrentHub } from "@sentry/core"; 2 | import { EventProcessor } from "@sentry/types"; 3 | 4 | import { Release } from "../../src/js/integrations/release"; 5 | 6 | jest.mock("@sentry/core", () => { 7 | const client = { 8 | getOptions: jest.fn(), 9 | }; 10 | 11 | const hub = { 12 | getClient: () => client, 13 | getIntegration: () => Release, 14 | }; 15 | 16 | return { 17 | addGlobalEventProcessor: jest.fn(), 18 | getCurrentHub: () => hub, 19 | }; 20 | }); 21 | 22 | jest.mock("../../src/js/wrapper", () => ({ 23 | NATIVE: { 24 | fetchRelease: async () => ({ 25 | build: "native_build", 26 | id: "native_id", 27 | version: "native_version", 28 | }), 29 | }, 30 | })); 31 | 32 | describe("Tests the Release integration", () => { 33 | test("Uses release from native SDK if release/dist are not present in options.", async () => { 34 | const releaseIntegration = new Release(); 35 | 36 | let eventProcessor: EventProcessor = () => null; 37 | 38 | // @ts-ignore Mock 39 | addGlobalEventProcessor.mockImplementation((e) => (eventProcessor = e)); 40 | releaseIntegration.setupOnce(); 41 | 42 | expect(addGlobalEventProcessor).toBeCalled(); 43 | 44 | const client = getCurrentHub().getClient(); 45 | 46 | // @ts-ignore Mock 47 | client.getOptions.mockImplementation(() => ({})); 48 | 49 | const event = await eventProcessor({}); 50 | 51 | expect(event?.release).toBe(`native_id@native_version+native_build`); 52 | expect(event?.dist).toBe("native_build"); 53 | }); 54 | 55 | test("Uses release and dist from options", async () => { 56 | const releaseIntegration = new Release(); 57 | 58 | let eventProcessor: EventProcessor = () => null; 59 | 60 | // @ts-ignore Mock 61 | addGlobalEventProcessor.mockImplementation((e) => (eventProcessor = e)); 62 | releaseIntegration.setupOnce(); 63 | 64 | expect(addGlobalEventProcessor).toBeCalled(); 65 | 66 | const client = getCurrentHub().getClient(); 67 | 68 | // @ts-ignore Mock 69 | client.getOptions.mockImplementation(() => ({ 70 | dist: "options_dist", 71 | release: "options_release", 72 | })); 73 | 74 | const event = await eventProcessor({}); 75 | 76 | expect(event?.release).toBe("options_release"); 77 | expect(event?.dist).toBe("options_dist"); 78 | }); 79 | 80 | test("Uses __sentry_release and __sentry_dist over everything else.", async () => { 81 | const releaseIntegration = new Release(); 82 | 83 | let eventProcessor: EventProcessor = () => null; 84 | 85 | // @ts-ignore Mock 86 | addGlobalEventProcessor.mockImplementation((e) => (eventProcessor = e)); 87 | releaseIntegration.setupOnce(); 88 | 89 | expect(addGlobalEventProcessor).toBeCalled(); 90 | 91 | const client = getCurrentHub().getClient(); 92 | 93 | // @ts-ignore Mock 94 | client.getOptions.mockImplementation(() => ({ 95 | dist: "options_dist", 96 | release: "options_release", 97 | })); 98 | 99 | const event = await eventProcessor({ 100 | extra: { 101 | __sentry_dist: "sentry_dist", 102 | __sentry_release: "sentry_release", 103 | }, 104 | }); 105 | 106 | expect(event?.release).toBe("sentry_release"); 107 | expect(event?.dist).toBe("sentry_dist"); 108 | }); 109 | }); 110 | -------------------------------------------------------------------------------- /sample/android/app/src/debug/java/io/sentry/sample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package io.sentry.sample; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /sample/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /sample/ios/sample.xcodeproj/xcshareddata/xcschemes/sample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /sample/ios/sample.xcodeproj/xcshareddata/xcschemes/sample-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sentry/react-native", 3 | "homepage": "https://github.com/getsentry/sentry-react-native", 4 | "repository": "https://github.com/getsentry/sentry-react-native", 5 | "version": "2.5.0-beta.1", 6 | "description": "Official Sentry SDK for react-native", 7 | "typings": "dist/js/index.d.ts", 8 | "types": "dist/js/index.d.ts", 9 | "typescript": { 10 | "definition": "dist/js/index.d.ts" 11 | }, 12 | "main": "dist/js/index.js", 13 | "scripts": { 14 | "build": "tsc -p tsconfig.build.json", 15 | "build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput", 16 | "clean": "rimraf dist coverage", 17 | "test": "jest", 18 | "lint": "eslint .", 19 | "test:watch": "jest --watch", 20 | "run-ios": "cd sample && yarn react-native run-ios", 21 | "run-android": "cd sample && yarn react-native run-android" 22 | }, 23 | "keywords": [ 24 | "react-native", 25 | "sentry", 26 | "crashreporting", 27 | "ios" 28 | ], 29 | "publishConfig": { 30 | "access": "public" 31 | }, 32 | "author": "Sentry", 33 | "license": "MIT", 34 | "//": [ 35 | "React version to be compatible with RN", 36 | "When bumping make sure to update the version of react, i.e: https://github.com/facebook/react-native/blob/v0.56.0/package.json" 37 | ], 38 | "peerDependencies": { 39 | "react": ">=16.4.1", 40 | "react-native": ">=0.56.0" 41 | }, 42 | "dependencies": { 43 | "@sentry/browser": "6.2.1", 44 | "@sentry/core": "6.2.1", 45 | "@sentry/hub": "6.2.1", 46 | "@sentry/integrations": "6.2.1", 47 | "@sentry/react": "6.2.1", 48 | "@sentry/tracing": "6.2.1", 49 | "@sentry/types": "6.2.1", 50 | "@sentry/utils": "6.2.1", 51 | "@sentry/wizard": "^1.2.2" 52 | }, 53 | "devDependencies": { 54 | "@sentry-internal/eslint-config-sdk": "6.2.1", 55 | "@sentry-internal/eslint-plugin-sdk": "6.2.1", 56 | "@sentry/typescript": "^5.20.0", 57 | "@types/jest": "^26.0.15", 58 | "@types/react": "^16.9.49", 59 | "@types/react-native": "^0.64.2", 60 | "babel-jest": "^26.1.0", 61 | "eslint": "^7.6.0", 62 | "eslint-plugin-react": "^7.20.6", 63 | "eslint-plugin-react-native": "^3.8.1", 64 | "jest": "^24.9.0", 65 | "prettier": "^2.0.5", 66 | "react": ">=16.4.1", 67 | "react-native": ">=0.56.0", 68 | "replace-in-file": "^6.0.0", 69 | "rimraf": "^3.0.0", 70 | "ts-jest": "^24.3.0", 71 | "typescript": "^3.4.5" 72 | }, 73 | "rnpm": { 74 | "commands": { 75 | "postlink": "node node_modules/@sentry/wizard/dist/bin.js -i reactNative -p ios android", 76 | "postunlink": "node node_modules/@sentry/wizard/dist/bin.js -i reactNative -p ios android --uninstall" 77 | }, 78 | "android": { 79 | "packageInstance": "new RNSentryPackage()" 80 | }, 81 | "ios": { 82 | "sharedLibraries": [ 83 | "libz" 84 | ] 85 | } 86 | }, 87 | "jest": { 88 | "collectCoverage": true, 89 | "preset": "react-native", 90 | "transform": { 91 | "^.+\\.(tsx)$": "/node_modules/react-native/jest/preprocessor.js", 92 | "^.+\\.(ts|tsx)$": "ts-jest" 93 | }, 94 | "globals": { 95 | "__DEV__": true, 96 | "ts-jest": { 97 | "tsConfig": "./tsconfig.json", 98 | "diagnostics": false 99 | } 100 | }, 101 | "moduleFileExtensions": [ 102 | "ts", 103 | "tsx", 104 | "js" 105 | ], 106 | "testPathIgnorePatterns": [ 107 | "/sample/" 108 | ], 109 | "testEnvironment": "node", 110 | "testMatch": [ 111 | "**/*.test.(ts|tsx)" 112 | ] 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /sample/src/screens/TrackerScreen.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {Button, View, StyleSheet, Text, ActivityIndicator} from 'react-native'; 3 | 4 | import * as Sentry from '@sentry/react-native'; 5 | 6 | /** 7 | * An example of how to add a Sentry Transaction to a React component manually. 8 | * So you can control all spans that belong to that one transaction. 9 | * 10 | * This screen calls an API to get the latest COVID-19 Data to display. We attach a span 11 | * to the fetch call and track the time it takes for Promise to resolve. 12 | */ 13 | const TrackerScreen = () => { 14 | const [cases, setCases] = React.useState<{ 15 | TotalConfirmed: number; 16 | TotalDeaths: number; 17 | TotalRecovered: number; 18 | } | null>(null); 19 | 20 | const loadData = () => { 21 | setCases(null); 22 | 23 | fetch('https://api.covid19api.com/summary', { 24 | method: 'GET', 25 | headers: { 26 | Accept: 'application/json', 27 | 'Content-Type': 'application/json', 28 | }, 29 | }) 30 | .then((response) => response.json()) 31 | .then((json) => { 32 | setCases(json.Global); 33 | }); 34 | }; 35 | 36 | React.useEffect(() => { 37 | loadData(); 38 | }, []); 39 | 40 | return ( 41 | 42 | 43 | Global COVID19 Cases 44 | 45 | 46 | {cases ? ( 47 | <> 48 | 53 | 58 | 63 | 64 | ) : ( 65 | 66 | )} 67 | 68 |