Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ Setup With Cocoapods
In order to use Sentry with cocoapods you have to install the packages with
``npm`` or ``yarn`` and link them locally in your ``Podfile``.

.. code-block:: bash
.. sourcecode:: bash
npm install --save react react-native react-native-sentry

After that change your ``Podfile`` to reference to the packages in your
``node_modules`` folder.

.. code-block:: bash
.. sourcecode:: ruby
platform :ios, '8.0'
use_frameworks!

Expand Down Expand Up @@ -187,13 +187,14 @@ These are functions you can call in your javascript code:

// disable stacktrace merging
Sentry.config("___DSN___", {
deactivateStacktraceMerging: true,
logLevel: SentryLog.Debug,
deactivateStacktraceMerging: true, // default: false | Deactivates the stacktrace merging feature
logLevel: SentryLog.Debug, // default SentryLog.None | Possible values: .None, .Error, .Debug, .Verbose
forceRavenClient: true // default false | This will force sentry to use the raven client instead the native client
// These two options will only be considered if stacktrace merging is active
// Here you can add modules that should be ignored or exclude modules
// that should no longer be ignored from stacktrace merging
// ignoreModulesExclude: ["I18nManager"], // Exclude is always stronger than include
// ignoreModulesInclude: ["RNSentry"], // Include modules that should be ignored too
// ignoreModulesExclude: ["I18nManager"], // default: [] | Exclude is always stronger than include
// ignoreModulesInclude: ["RNSentry"], // default: [] | Include modules that should be ignored too
// ---------------------------------
}).install();

Expand Down
75 changes: 28 additions & 47 deletions lib/Sentry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
NativeModules
} from 'react-native';
import Raven from 'raven-js';
require('raven-js/plugins/react-native')(Raven);
import Raven from 'raven-js';;

const {
RNSentry
Expand Down Expand Up @@ -61,10 +60,10 @@ export const SentryLog = {

export class Sentry {
static install() {
if (RNSentry && RNSentry.nativeClientAvailable) {
Sentry._client = new NativeClient(Sentry._dsn, Sentry._options);
if (RNSentry && RNSentry.nativeClientAvailable && Sentry.options.forceRavenClient === false) {
Sentry._client = new NativeClient(Sentry._dsn, Sentry.options);
} else {
Sentry._client = new RavenClient(Sentry._dsn, Sentry._options);
Sentry._client = new RavenClient(Sentry._dsn, Sentry.options);
}
}

Expand All @@ -73,7 +72,12 @@ export class Sentry {
throw new Error('Sentry: A DSN must be provided');
}
Sentry._dsn = dsn;
Sentry._options = options;
Sentry.options = {
logLevel: SentryLog.None,
forceRavenClient: false,
}
Object.assign(Sentry.options, options);
Sentry._originalConsole = console || {};
return Sentry;
}

Expand Down Expand Up @@ -102,23 +106,11 @@ export class Sentry {
}

static log = (level, message) => {
if (Sentry._options && Sentry._options.logLevel) {
if (Sentry._options.logLevel < level) {
if (Sentry.options && Sentry.options.logLevel) {
if (Sentry.options.logLevel < level) {
return;
}
switch (level) {
case SentryLog.Error:
console.error(message);
break;
case SentryLog.Debug:
console.debug(message);
break;
case SentryLog.Verbose:
console.log(message);
break;
default:
return
}
Sentry._originalConsole.log(message);
}
}
}
Expand All @@ -134,24 +126,15 @@ class NativeClient {

this._dsn = dsn;
this._activatedMerging = false;
RNSentry.startWithDsnString(this._dsn);

this._deactivateStacktraceMerging = false;
if (options && options.deactivateStacktraceMerging) {
this._deactivateStacktraceMerging = true;
this.options = {
ignoreModulesExclude: [],
ignoreModulesInclude: [],
deactivateStacktraceMerging: false
}
if (options && options.logLevel) {
RNSentry.setLogLevel(options.logLevel);
}
this._ignoreModulesExclude = [];
if (options && options.ignoreModulesExclude) {
this._ignoreModulesExclude = options.ignoreModulesExclude;
}
this._ignoreModulesInclude = [];
if (options && options.ignoreModulesInclude) {
this._ignoreModulesInclude = options.ignoreModulesInclude;
}
if (this._deactivateStacktraceMerging === false) {
Object.assign(this.options, options);

RNSentry.startWithDsnString(this._dsn);
if (this.options.deactivateStacktraceMerging === false) {
this._activateStacktraceMerging();
}
}
Expand Down Expand Up @@ -200,9 +183,9 @@ class NativeClient {
this._ignoredModules = {};
__fbBatchedBridgeConfig.remoteModuleConfig.forEach((module, moduleID) => {
if (module !== null &&
this._ignoreModulesExclude.indexOf(module[0]) == -1 &&
this.options.ignoreModulesExclude.indexOf(module[0]) == -1 &&
(DEFAULT_MODULE_IGNORES.indexOf(module[0]) >= 0 ||
this._ignoreModulesInclude.indexOf(module[0]) >= 0)) {
this.options.ignoreModulesInclude.indexOf(module[0]) >= 0)) {
this._ignoredModules[moduleID] = true;
}
});
Expand Down Expand Up @@ -232,15 +215,13 @@ class RavenClient {
if (dsn.constructor !== String) {
throw new Error('SentryClient: A DSN must be provided');
}

this._dsn = dsn;
if (options === null || options === undefined) {
options = {};
this.options = {
allowSecretKey: true,
}
Object.assign(options, {
allowSecretKey: true
});
Raven.config(dsn, options).install();
Object.assign(this.options, options);
Raven.addPlugin(require('./raven-plugin'));
Raven.config(dsn, this.options).install();
}

crash = () => {
Expand Down
Loading