Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
react-native-sentry
Advanced tools
Requirments:
react-native >= 0.41
sentry-cli > 0.25:
https://github.com/getsentry/sentry-cli
OR
brew install getsentry/tools/sentry-cli
Sentry can provide mixed stacktraces, which means if your app happens to crash on the native side you will also see the last call from javascript.
If you don't have a react native project up and running follow this guide. https://facebook.github.io/react-native/docs/getting-started.html
Start with adding sentry:
$ npm install react-native-sentry --save
$ react-native link react-native-sentry
react-native init AwesomeProject
cd AwesomeProject
Add framework search paths:
$(SRCROOT)/../node_modules/react-native-sentry/ios
Always embed swift libraries:
Copy files phase:
Copy frameworks:
Add run script phase to upload your debug symbols and source maps:
Change this variables with your values:
SENTRY_ORG
SENTRY_PROJECT
SENTRY_AUTH_TOKEN
if which sentry-cli >/dev/null; then
export SENTRY_ORG=YOUR-ORG
export SENTRY_PROJECT=YOUR-PROJECT
export SENTRY_AUTH_TOKEN=YOUR-AUTH-TOKEN
ERROR=$(sentry-cli upload-dsym 2>&1 >/dev/null)
if [ ! -z "$ERROR" ]; then
echo "warning: sentry-cli - $ERROR"
fi
RELEASE=$(/usr/libexec/PlistBuddy -c "print :CFBundleShortVersionString" $INFOPLIST_FILE)
BUILD=$(/usr/libexec/PlistBuddy -c "print :CFBundleVersion" $INFOPLIST_FILE)
../node_modules/react-native-sentry/bin/sourcemap_upload $RELEASE $BUILD
else
echo "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases"
fi
Add sentry to your index.ios.js
...
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import {
SentryClient,
SentrySeverity,
SentryLog,
User
} from 'react-native-sentry';
SentryClient.setLogLevel(SentryLog.Debug);
SentryClient.shared = new SentryClient("Your DSN");
SentryClient.shared.activateStacktraceMerging(require('BatchedBridge'), require('parseErrorStack'));
export default class AwesomeProject extends Component {
...
Change AppDelegate.m
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RNSentry.h>
@interface AppDelegate()
@property (nonatomic, strong) RNSentry *sentry;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
self.sentry = [[RNSentry alloc] init];
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
moduleProvider:^NSArray<id<RCTBridgeModule>> *{
id<RCTExceptionsManagerDelegate> customDelegate = self.sentry;
return @[[[RCTExceptionsManager alloc] initWithDelegate:customDelegate]];
}
launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"AwesomeProject" initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
These are functions you can call in your javascript code:
SentryClient.shared.setExtras({
"a_thing": 3,
"some_things": {"green": "red"},
"foobar": ["a", "b", "c"],
"react": true,
"float": 2.43
});
SentryClient.shared.setTags({
"environment": "production",
"react": true
});
SentryClient.shared.setUser(new User(
"12341",
"john@apple.com",
"username",
{
"is_admin": false
}
));
SentryClient.shared.captureMessage("TEST message", SentrySeverity.Warning);
// This will trigger a crash in the native sentry client
//SentryClient.shared.nativeCrash();
FAQs
Official Sentry SDK for react-native
The npm package react-native-sentry receives a total of 451 weekly downloads. As such, react-native-sentry popularity was classified as not popular.
We found that react-native-sentry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.