Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Introduce setEnvironment method #583

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 6 additions & 2 deletions lib/RavenClient.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Raven from 'raven-js';
import {Sentry, SentryLog} from './Sentry';
import { Sentry, SentryLog } from './Sentry';

export class RavenClient {
constructor(dsn, options) {
Expand Down Expand Up @@ -52,7 +52,7 @@ export class RavenClient {
});
Raven.setBreadcrumbCallback(Sentry._breadcrumbCallback);
const oldCaptureBreadcrumb = Raven.captureBreadcrumb;
Raven.captureBreadcrumb = function(obj) {
Raven.captureBreadcrumb = function (obj) {
if (obj.data && typeof obj.data === 'object') {
obj.data = Object.assign({}, obj.data);
}
Expand Down Expand Up @@ -97,6 +97,10 @@ export class RavenClient {
Raven.setRelease(release);
}

setEnvironment(environment) {
Raven.setEnvironment(environment);
}

clearContext() {
return Raven.clearContext();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Sentry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export class Sentry {

static setRelease(release: string): void;

static setEnvironment(environment: string): void;

static setDist(dist: string): void;

static setVersion(version: string): void;
Expand Down
14 changes: 10 additions & 4 deletions lib/Sentry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {NativeModules, NativeEventEmitter} from 'react-native';
const {RNSentry, RNSentryEventEmitter} = NativeModules;
import { NativeModules, NativeEventEmitter } from 'react-native';
const { RNSentry, RNSentryEventEmitter } = NativeModules;

import {RavenClient} from './RavenClient';
import {NativeClient} from './NativeClient';
import { RavenClient } from './RavenClient';
import { NativeClient } from './NativeClient';

export const SentrySeverity = {
Fatal: 'fatal',
Expand Down Expand Up @@ -176,6 +176,12 @@ export const Sentry = {
if (Sentry._ravenClient) Sentry._ravenClient.setRelease(release);
},

setEnvironment(environment) {
Sentry._log('react-native-sentry (setEnvironment)');
Sentry._setInternalOption('environment', environment);
if (Sentry._ravenClient) Sentry._ravenClient.setEnvironment(environment);
},

setDist(dist) {
Sentry._setInternalOption('dist', dist);
},
Expand Down