feat(nc): monitoring update (#3609)

This commit is contained in:
Pierre Dommerc
2023-06-28 12:20:29 +02:00
committed by pierre
parent fcc5398aab
commit a0c6efafd2
11 changed files with 47 additions and 15 deletions
+2 -1
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { Apps, HelpOutline, Settings } from '@mui/icons-material';
import { Apps, HelpOutline, Settings, BugReport } from '@mui/icons-material';
import { Stack, Link, List, ListItem, ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
import { Link as RouterLink } from 'react-router-dom';
import { AppVersion } from 'src/components/AppVersion';
@@ -7,6 +7,7 @@ import { AppVersion } from 'src/components/AppVersion';
const menuSchema = [
{ title: 'Supported apps', icon: Apps, path: 'apps' },
{ title: 'How to connect guide', icon: HelpOutline, path: 'guide' },
{ title: 'Please help us improve the app', icon: BugReport, path: 'monitoring' },
{ title: 'Settings', icon: Settings, path: 'settings' },
];
@@ -34,10 +34,6 @@ export const MonitoringSettings = () => {
occur or if the app crashes, it will automatically send a report. Also it tracks various performance
metrics. We use sentry.io service to handle this.
</FormHelperText>
<FormHelperText sx={{ m: 0, mb: 2 }}>
Note: A report can include your external IP, this can be useful to catch issues related to IP location.
All recorded data is used by Nym developers and for app development purposes only.
</FormHelperText>
</FormControl>
<Stack direction="row" gap={1} alignItems="center">
<WarningIcon color="warning" fontSize="small" />
@@ -7,7 +7,6 @@ import { toggleLogViewer } from 'src/utils';
const menuSchema = [
{ title: 'Select your gateway', path: 'gateway' },
{ title: 'Select a service provider', path: 'service-provider' },
{ title: 'Help improve the app', path: 'monitoring' },
];
export const SettingsMenu = () => (
+1 -1
View File
@@ -25,11 +25,11 @@ export const AppRoutes = () => {
<Route index element={<Menu />} />
<Route path="apps" element={<CompatibleApps />} />
<Route path="guide" element={<HelpGuide />} />
<Route path="monitoring" element={<MonitoringSettings />} />
<Route path="settings">
<Route index element={<SettingsMenu />} />
<Route path="gateway" element={<GatewaySettings />} />
<Route path="service-provider" element={<ServiceProviderSettings />} />
<Route path="monitoring" element={<MonitoringSettings />} />
</Route>
</Route>
</RoutesContainer>
+2
View File
@@ -43,6 +43,8 @@ async function initSentry() {
getVersion().then((version) => {
Sentry.setTag('app_version', version);
});
Sentry.setUser({ id: 'nym', ip_address: undefined });
}
export default initSentry;
+1 -1
View File
@@ -99,7 +99,6 @@ android {
}
dependencies {
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.2'
@@ -124,4 +123,5 @@ dependencies {
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
implementation 'com.github.kittinunf.fuel:fuel:3.0.0-alpha1'
implementation 'io.sentry:sentry-android:6.24.0'
}
@@ -2,6 +2,8 @@ package net.nymtech.nyms5
import android.app.Application
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.util.Log
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
@@ -9,11 +11,15 @@ import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import androidx.work.Configuration
import androidx.work.DelegatingWorkerFactory
import io.sentry.Scope
import io.sentry.Sentry
import io.sentry.android.core.SentryAndroid
import io.sentry.protocol.User
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
val monitoringKey = booleanPreferencesKey("monitoring")
@@ -40,11 +46,34 @@ class App : Application(), Configuration.Provider {
options.dsn =
"https://6872f5818bc147ef9c0fce114fcaac8a@o967446.ingest.sentry.io/4505306218102784"
options.enableAllAutoBreadcrumbs(true)
options.isEnableUserInteractionTracing = true
options.isEnableUserInteractionBreadcrumbs = true
// TODO should be adjusted in production env
options.sampleRate = 1.0
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0
}
Sentry.configureScope { scope: Scope ->
val packageManager = applicationContext.packageManager
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager.getPackageInfo(
packageName,
PackageManager.PackageInfoFlags.of(0)
)
} else {
packageManager.getPackageInfo(packageName, 0)
}
scope.setTag("app_version", packageInfo.versionName)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
scope.setTag("app_version_code", packageInfo.longVersionCode.toString())
}
}
val user = User()
user.id = "nym"
Sentry.setUser(user)
}
}
}
@@ -50,6 +50,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
@@ -249,7 +250,7 @@ fun S5ClientSwitch(
Spacer(modifier = modifier.width(14.dp))
Switch(checked = connected, enabled = !loading, onCheckedChange = {
onSwitch(!connected)
})
}, modifier = Modifier.testTag("switch_connect"))
}
if (connected && !loading) {
Column(modifier = modifier.padding(16.dp)) {
@@ -332,12 +333,10 @@ fun Monitoring(
tint = Color.Yellow
)
Spacer(modifier = modifier.width(16.dp))
Text(stringResource(R.string.monitoring_desc_3), color = Color.Yellow)
Text(stringResource(R.string.monitoring_desc_2), color = Color.Yellow)
}
Spacer(modifier = modifier.height(18.dp))
Text(stringResource(R.string.monitoring_desc_1))
Spacer(modifier = modifier.height(18.dp))
Text(stringResource(R.string.monitoring_desc_2))
}
}
@@ -1,6 +1,7 @@
package net.nymtech.nyms5
import android.util.Log
import io.sentry.Sentry
const val nymNativeLib = "nym_socks5_listener"
@@ -27,6 +28,7 @@ class NymProxy {
startClient(serviceProvider, onStartCbObj, onStopCbObj)
} catch (e: Throwable) {
Log.e(tag, "$nymNativeLib:startClient internal error: $e")
Sentry.captureException(e)
}
}
@@ -36,6 +38,7 @@ class NymProxy {
stopClient()
} catch (e: Throwable) {
Log.e(tag, "$nymNativeLib:stopClient internal error: $e")
Sentry.captureException(e)
}
}
@@ -50,6 +53,7 @@ class NymProxy {
}
} catch (e: Throwable) {
Log.e(tag, "$nymNativeLib:getClientState internal error: $e")
Sentry.captureException(e)
}
return State.UNINITIALIZED
}
@@ -17,6 +17,7 @@ import androidx.work.WorkerParameters
import androidx.work.workDataOf
import fuel.Fuel
import fuel.get
import io.sentry.Sentry
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
@@ -100,6 +101,7 @@ class ProxyWorker(
tag,
"failed to make the work run in the context of a foreground service"
)
Sentry.captureException(e)
}
return try {
@@ -127,6 +129,7 @@ class ProxyWorker(
tag,
"an error occurred while fetching the service providers list: $e"
)
Sentry.captureException(e)
Log.w(tag, "using a default service provider $defaultSp")
}
@@ -139,6 +142,7 @@ class ProxyWorker(
Result.success()
} catch (e: Throwable) {
Log.e(tag, "error: ${e.message}")
Sentry.captureException(e)
Result.failure()
}
}
@@ -12,7 +12,5 @@
<string name="default_sp">DpB3cHAchJiNBQi5FrZx2csXb1mrHkpYh9Wzf8Rjsuko.ANNWrvHqMYuertHGHUrZdBntQhpzfbWekB39qez9U2Vx@2BuMSfMW3zpeAjKXyKLhmY4QW1DXurrtSPEJ6CjX3SEh</string>
<string name="connected_text">Connected to the mixnet</string>
<string name="monitoring_desc_1">Help Nym developers to fix errors, crashes and improve the application by enabling this option. If errors occur or if the app crashes, it will automatically send a report. Also it tracks various performance metrics. We use sentry.io service to handle this.</string>
<string name="monitoring_desc_2">Note: A report can include your external IP, this can be useful to catch issues related to IP location.
All recorded data is used by Nym developers and for app development purposes only.</string>
<string name="monitoring_desc_3">You must restart the application for the change to take effect.</string>
<string name="monitoring_desc_2">You must restart the application for the change to take effect.</string>
</resources>