Skip to content

Commit

Permalink
chore: Add config for exposing environment variables (#318)
Browse files Browse the repository at this point in the history
* add react-native config package

* update pods

* update sentry config

* update docs
  • Loading branch information
muhsin-k committed Mar 16, 2021
1 parent ef9e5ad commit 3dffbc4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions .env.example
@@ -0,0 +1 @@
SENTRY_DSN=
7 changes: 1 addition & 6 deletions CONTRIBUTING.md
Expand Up @@ -42,13 +42,8 @@ And install dependencies

Create a new project in [Sentry](https://sentry.io/for/react-native/)

Create file sentry under `sentry.js` in root of the project.

Add the following contents.

```
export const SENTRY_TOKEN_URL =<SENTRY_TOKEN_URL>;
```
Add `SENTRY_DSN` value in `.env` file.

If you want to supports native crashes, link the sentry SDK to your native projects.
Run the command
Expand Down
1 change: 1 addition & 0 deletions android/app/build.gradle
Expand Up @@ -235,3 +235,4 @@ task copyDownloadableDepsToLibs(type: Copy) {
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
7 changes: 2 additions & 5 deletions index.js
@@ -1,14 +1,11 @@
import { AppRegistry } from 'react-native';
import * as Sentry from '@sentry/react-native';

import Config from 'react-native-config';
import { name as appName } from './app.json';

import { SENTRY_TOKEN_URL } from './sentry';

import App from './src/app';

AppRegistry.registerComponent(appName, () => App);

Sentry.init({
dsn: SENTRY_TOKEN_URL,
dsn: Config.SENTRY_DSN,
});
10 changes: 9 additions & 1 deletion ios/Podfile.lock
Expand Up @@ -296,6 +296,10 @@ PODS:
- React-cxxreact (= 0.63.3)
- React-jsi (= 0.63.3)
- React-jsinspector (0.63.3)
- react-native-config (1.4.2):
- react-native-config/App (= 1.4.2)
- react-native-config/App (1.4.2):
- React-Core
- react-native-document-picker (5.0.0):
- React-Core
- react-native-image-picker (3.1.4):
Expand Down Expand Up @@ -445,6 +449,7 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-config (from `../node_modules/react-native-config`)
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
Expand Down Expand Up @@ -537,6 +542,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-config:
:path: "../node_modules/react-native-config"
react-native-document-picker:
:path: "../node_modules/react-native-document-picker"
react-native-image-picker:
Expand Down Expand Up @@ -639,6 +646,7 @@ SPEC CHECKSUMS:
React-jsi: df07aa95b39c5be3e41199921509bfa929ed2b9d
React-jsiexecutor: b56c03e61c0dd5f5801255f2160a815f4a53d451
React-jsinspector: 8e68ffbfe23880d3ee9bafa8be2777f60b25cbe2
react-native-config: c98128a72bc2c3a1ca72caec0b021f0fa944aa29
react-native-document-picker: ca0c8769c3848866970dc9164e809c6ea45cb5d6
react-native-image-picker: 28d8d1f5a643119876b8b2c7d4d1dcfb2b232dd4
react-native-netinfo: 30fb89fa913c342be82a887b56e96be6d71201dd
Expand Down Expand Up @@ -675,4 +683,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 359eeed31941826235cdc4a3c6b998cb2e176764

COCOAPODS: 1.10.0
COCOAPODS: 1.10.1
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -42,6 +42,7 @@
"react-native-actions-sheet": "^0.4.2",
"react-native-animatable": "^1.3.3",
"react-native-background-color": "^0.0.8",
"react-native-config": "^1.4.2",
"react-native-device-info": "^5.6.5",
"react-native-document-picker": "^5.0.0",
"react-native-exception-handler": "^2.10.9",
Expand All @@ -64,7 +65,8 @@
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"tcomb-form-native": "^0.6.20",
"validator": "^13.5.2"
"validator": "^13.5.2",
"yarn": "^1.22.10"
},
"devDependencies": {
"@babel/core": "^7.8.4",
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Expand Up @@ -7374,6 +7374,11 @@ react-native-background-color@^0.0.8:
resolved "https://registry.yarnpkg.com/react-native-background-color/-/react-native-background-color-0.0.8.tgz#661f737156a18a86ece362126e9c97e33fa42ed2"
integrity sha512-Or89KCBNyFsD0234g/MgWyRrhwtd5egHXdqUwal1e5FKpum8d/x1y5PQqF3OUFR0W/ztp5Vt3FaLc/LEY0Fy+Q==

react-native-config@^1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-1.4.2.tgz#cc39f22ed72c5cb06af1adf0ba70ef01593900b4"
integrity sha512-iTvCvThvFTH7SdiBcsxYtpLy86zglsh51ZBqFPPZ75tdrQMdlRnDNnb86kNjQf03KT0qs1nCMLRejfPMIim8iA==

react-native-device-info@^5.6.5:
version "5.6.5"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-5.6.5.tgz#3f18d7c38b21cfc475163351a9aae6e9037a43a0"
Expand Down Expand Up @@ -9490,3 +9495,8 @@ yargs@^15.1.0, yargs@^15.3.1:
which-module "^2.0.0"
y18n "^4.0.0"
yargs-parser "^18.1.2"

yarn@^1.22.10:
version "1.22.10"
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.10.tgz#c99daa06257c80f8fa2c3f1490724e394c26b18c"
integrity sha512-IanQGI9RRPAN87VGTF7zs2uxkSyQSrSPsju0COgbsKQOOXr5LtcVPeyXWgwVa0ywG3d8dg6kSYKGBuYK021qeA==

0 comments on commit 3dffbc4

Please sign in to comment.