-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sentry to sync app (opt out available)
- Loading branch information
1 parent
5bb6af7
commit 9c5c995
Showing
11 changed files
with
393 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,7 @@ yarn-error.* | |
|
||
# typescript | ||
*.tsbuildinfo | ||
|
||
|
||
*.log | ||
.env.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,14 +11,43 @@ 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) } } | ||
const get = async (key) => { try { const value = await AsyncStorage.getItem(key); if (value !== null) { try { return JSON.parse(value) } catch { return value } } } catch (e) { console.log(e) } } | ||
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://[email protected]/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() { | |
}} | ||
/> | ||
|
||
<View style={{ flexDirection: 'row', alignItems: 'center', marginVertical: 10 }}> | ||
<Text style={{ fontSize: 15 }}>Enable Sentry:</Text> | ||
<Switch | ||
value={isSentryEnabled} | ||
onValueChange={async (value) => { | ||
if (value) { | ||
Sentry.init({ | ||
dsn: 'https://[email protected]/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()); | ||
}} | ||
/> | ||
</View> | ||
|
||
<View style={{ marginTop: 20 }}> | ||
<Button | ||
title="Sync Now" | ||
|
@@ -419,6 +477,36 @@ export default function App() { | |
}} | ||
/> | ||
|
||
<View style={{ flexDirection: 'row', alignItems: 'center', marginVertical: 10 }}> | ||
<Text style={{ fontSize: 15 }}>Enable Sentry:</Text> | ||
<Switch | ||
value={isSentryEnabled} | ||
defaultValue={isSentryEnabled} | ||
onValueChange={async (value) => { | ||
if (value) { | ||
Sentry.init({ | ||
dsn: 'https://[email protected]/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()); | ||
}} | ||
/> | ||
</View> | ||
|
||
<Button | ||
title="Login" | ||
onPress={() => { | ||
|
@@ -431,7 +519,7 @@ export default function App() { | |
<Toast /> | ||
</View> | ||
); | ||
} | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> | ||
<uses-permission android:name="android.permission.VIBRATE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/> | ||
|
||
<uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED"/> | ||
<uses-permission android:name="android.permission.health.READ_BASAL_BODY_TEMPERATURE"/> | ||
<uses-permission android:name="android.permission.health.READ_BASAL_METABOLIC_RATE"/> | ||
|
@@ -16,8 +16,8 @@ | |
<uses-permission android:name="android.permission.health.READ_BONE_MASS"/> | ||
<uses-permission android:name="android.permission.health.READ_CERVICAL_MUCUS"/> | ||
<uses-permission android:name="android.permission.health.READ_DISTANCE"/> | ||
<uses-permission android:name="android.permission.health.READ_EXERCISE"/> | ||
<uses-permission android:name="android.permission.health.READ_ELEVATION_GAINED"/> | ||
<uses-permission android:name="android.permission.health.READ_EXERCISE"/> | ||
<uses-permission android:name="android.permission.health.READ_FLOORS_CLIMBED"/> | ||
<uses-permission android:name="android.permission.health.READ_HEART_RATE"/> | ||
<uses-permission android:name="android.permission.health.READ_HEART_RATE_VARIABILITY"/> | ||
|
@@ -39,9 +39,6 @@ | |
<uses-permission android:name="android.permission.health.READ_VO2_MAX"/> | ||
<uses-permission android:name="android.permission.health.READ_WEIGHT"/> | ||
<uses-permission android:name="android.permission.health.READ_WHEELCHAIR_PUSHES"/> | ||
|
||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> | ||
|
||
<queries> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW"/> | ||
|
@@ -50,26 +47,14 @@ | |
</intent> | ||
</queries> | ||
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme"> | ||
<meta-data | ||
android:name="com.supersami.foregroundservice.notification_channel_name" | ||
android:value="Sticky Title" | ||
/> | ||
<meta-data | ||
android:name="com.supersami.foregroundservice.notification_channel_description" | ||
android:value="Sticky Description." | ||
/> | ||
<meta-data | ||
android:name="com.supersami.foregroundservice.notification_color" | ||
android:resource="@color/blue" | ||
/> | ||
<service android:name="com.supersami.foregroundservice.ForegroundService" android:foregroundServiceType="dataSync"></service> | ||
<service android:name="com.supersami.foregroundservice.ForegroundServiceTask" android:foregroundServiceType="dataSync"></service> | ||
|
||
|
||
<meta-data android:name="com.supersami.foregroundservice.notification_channel_description" android:value="Sticky Description."/> | ||
<meta-data android:name="com.supersami.foregroundservice.notification_channel_name" android:value="Sticky Title"/> | ||
<meta-data android:name="com.supersami.foregroundservice.notification_color" android:resource="@color/blue"/> | ||
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/> | ||
|
||
<service android:name="com.supersami.foregroundservice.ForegroundService" android:foregroundServiceType="dataSync"/> | ||
<service android:name="com.supersami.foregroundservice.ForegroundServiceTask" android:foregroundServiceType="dataSync"/> | ||
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
@@ -80,42 +65,36 @@ | |
<category android:name="android.intent.category.DEFAULT"/> | ||
<category android:name="android.intent.category.BROWSABLE"/> | ||
<data android:scheme="dev.shuchir.hcgateway"/> | ||
<data android:scheme="exp+hcgateway"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" /> | ||
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name=".PermissionsRationaleActivity" | ||
android:exported="true"> | ||
<activity android:name=".PermissionsRationaleActivity" android:exported="true"> | ||
<intent-filter> | ||
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" /> | ||
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
<!-- For versions starting Android 14, create an activity alias to show the rationale | ||
of Health Connect permissions once users click the privacy policy link. --> | ||
<activity-alias | ||
android:name="ViewPermissionUsageActivity" | ||
android:exported="true" | ||
android:targetActivity=".MainActivity" | ||
android:permission="android.permission.START_VIEW_PERMISSION_USAGE"> | ||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/> | ||
<activity-alias android:name="ViewPermissionUsageActivity" android:exported="true" android:targetActivity=".MainActivity" android:permission="android.permission.START_VIEW_PERMISSION_USAGE"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE" /> | ||
<category android:name="android.intent.category.HEALTH_PERMISSIONS" /> | ||
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE"/> | ||
<category android:name="android.intent.category.HEALTH_PERMISSIONS"/> | ||
</intent-filter> | ||
</activity-alias> | ||
|
||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/> | ||
<activity-alias android:name="ViewPermissionUsageActivity" android:exported="true" android:targetActivity=".MainActivity" android:permission="android.permission.START_VIEW_PERMISSION_USAGE"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE"/> | ||
<category android:name="android.intent.category.HEALTH_PERMISSIONS"/> | ||
</intent-filter> | ||
</activity-alias> | ||
|
||
<meta-data android:name="io.sentry.dsn" android:value="https://[email protected]/6" /> | ||
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" /> | ||
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" /> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
|
||
<resources> | ||
<item name="blue" type="color">#00C4D1 | ||
<resources> | ||
<item name="blue" type="color">#00C4D1
 | ||
</item> | ||
<integer-array name="androidcolors"> | ||
<integer-array name="androidcolors"> | ||
<item>@color/blue</item> | ||
</integer-array> | ||
|
||
<color name="colorPrimary">#00C4D1</color> | ||
<color name="iconBackground">#00C4D1</color> | ||
<color name="splashscreen_background">#FFFFFF</color> | ||
</resources> | ||
</integer-array> | ||
<color name="colorPrimary">#023c69</color> | ||
<color name="iconBackground">#ffffff</color> | ||
<color name="splashscreen_background">#ffffff</color> | ||
<color name="colorPrimaryDark">#ffffff</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
defaults.url=https://sentry.shuchir.dev/ | ||
defaults.org=sentry | ||
defaults.project=hcgateway-app | ||
# Using SENTRY_AUTH_TOKEN environment variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { getSentryExpoConfig } = require("@sentry/react-native/metro"); | ||
|
||
const config = getSentryExpoConfig(__dirname); | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.