diff --git a/README.md b/README.md index e4229e3..b319c72 100644 --- a/README.md +++ b/README.md @@ -152,8 +152,20 @@ You can self host the server and database. To do this, follow the steps below: - run `pip install -r requirements.txt` - rename `.env.example` to `.env` and fill in the values - run `python3 main.py` to start the server + +To run the mobile application: - in another window/tab, `cd` into the app/ folder - run `npm install` +- If you wish to remove sentry: +``` +yarn remove @sentry/react-native +npx @sentry/wizard -i reactNative -p android --uninstall +``` +- If you wish to change sentry to your own instance: + - Change the `dsn` in `App.js` to your own DSN + - Change the server, org name, and project name in app.json + - Change these details again in android/sentry.properties + - Change the DSN in the AndroidManifest.xml - run `npx patch-package` to apply a patch to the foreground service library - run `npm run android` to start the application, or follow the instructions at https://medium.com/geekculture/react-native-generate-apk-debug-and-release-apk-4e9981a2ea51 to build an APK file. - It is also possible to now use eas build to build the APK file. You can find more at https://docs.expo.dev/build/eas-build/ **NOTE: This must be a local build, since you need to run patch-package before building the APK file.** \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore index 05647d5..238b285 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -33,3 +33,7 @@ yarn-error.* # typescript *.tsbuildinfo + + +*.log +.env.local diff --git a/app/App.js b/app/App.js index 96cb928..c6c14b4 100644 --- a/app/App.js +++ b/app/App.js @@ -1,4 +1,4 @@ -import { StyleSheet, Text, View, TextInput, Button } from 'react-native'; +import { StyleSheet, Text, View, TextInput, Button, Switch } from 'react-native'; import React from 'react'; import { initialize, @@ -11,7 +11,7 @@ import Toast from 'react-native-toast-message'; import axios from 'axios'; import ReactNativeForegroundService from '@supersami/rn-foreground-service'; import {requestNotifications} from 'react-native-permissions'; -ReactNativeForegroundService.register(); +import * as Sentry from '@sentry/react-native'; const setObj = async (key, value) => { try { const jsonValue = JSON.stringify(value); await AsyncStorage.setItem(key, jsonValue) } catch (e) { console.log(e) } } const setPlain = async (key, value) => { try { await AsyncStorage.setItem(key, value) } catch (e) { console.log(e) } } @@ -19,6 +19,35 @@ const get = async (key) => { try { const value = await AsyncStorage.getItem(key) const delkey = async (key, value) => { try { await AsyncStorage.removeItem(key) } catch (e) { console.log(e) } } const getAll = async () => { try { const keys = await AsyncStorage.getAllKeys(); return keys } catch (error) { console.error(error) } } +let isSentryEnabled = true; +get('sentryEnabled') + .then(res => { + if (res != "false") { + Sentry.init({ + dsn: 'https://e4a201b96ea602d28e90b5e4bbe67aa6@sentry.shuchir.dev/6', + // enableSpotlight: __DEV__, + }); + Toast.show({ + type: 'success', + text1: "Sentry enabled from settings", + }); + } else { + isSentryEnabled = false; + Toast.show({ + type: 'info', + text1: "Sentry is disabled", + }); + } + }) + .catch(err => { + console.log(err); + Toast.show({ + type: 'error', + text1: "Failed to check Sentry settings", + }); + }); +ReactNativeForegroundService.register(); + let login; let apiBase = 'https://api.hcgateway.shuchir.dev'; let lastSync = null; @@ -326,6 +355,35 @@ export default function App() { }} /> + + Enable Sentry: + { + if (value) { + Sentry.init({ + dsn: 'https://e4a201b96ea602d28e90b5e4bbe67aa6@sentry.shuchir.dev/6', + }); + Toast.show({ + type: 'success', + text1: "Sentry enabled", + }); + isSentryEnabled = true; + forceUpdate(); + } else { + Sentry.close(); + Toast.show({ + type: 'success', + text1: "Sentry disabled", + }); + isSentryEnabled = false; + forceUpdate(); + } + await setPlain('sentryEnabled', value.toString()); + }} + /> + +