Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix bugs (#327)

Artem Rozzhyvina0db5f61988a
diff --git a/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsx b/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsx
index 497ae9745..5cc196796 100644
--- a/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsx
+++ b/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsx
@@ -50,8 +50,8 @@ const ProjectAlertsSettings = ({
}): JSX.Element => {
const navigate = useNavigate()
const { id, pid }: {
- id: string
- pid: string
+ id?: string
+ pid?: string
} = useParams()
const { pathname }: {
pathname: string
@@ -61,7 +61,7 @@ const ProjectAlertsSettings = ({
[key: string]: string | number | null | undefined
}) => string
} = useTranslation('common')
- const isSettings: boolean = !_isEmpty(id) && (_replace(_replace(routes.alert_settings, ':id', id), ':pid', pid) === pathname)
+ const isSettings: boolean = !_isEmpty(id) && (_replace(_replace(routes.alert_settings, ':id', id as string), ':pid', pid as string) === pathname)
const alert = useMemo(() => _find(alerts, { id }), [alerts, id])
const [form, setForm] = useState<Partial<IAlerts>>({
pid,
@@ -144,11 +144,11 @@ const ProjectAlertsSettings = ({
} = {}
if (_isEmpty(form.name) || _size(form.name) < 3) {
- allErrors.name = t('profileSettings.nameError')
+ allErrors.name = t('alert.noNameError')
}
if (Number.isNaN(_toNumber(form.queryValue))) {
- allErrors.queryValue = t('alertsSettings.queryValueError')
+ allErrors.queryValue = t('alert.queryValueError')
}
const valid = _isEmpty(_keys(allErrors))
@@ -159,7 +159,7 @@ const ProjectAlertsSettings = ({
const onSubmit = (data: Partial<IAlerts>) => {
if (isSettings) {
- updateAlert(id, data)
+ updateAlert(id as string, data)
.then((res) => {
navigate(`/projects/${pid}?tab=${PROJECT_TABS.alerts}`)
setProjectAlerts([..._filter(alerts, (a) => a.id !== id), res])
@@ -183,6 +183,11 @@ const ProjectAlertsSettings = ({
}
const onDelete = () => {
+ if (!id) {
+ showError('Something went wrong')
+ return
+ }
+
deleteAlert(id)
.then(() => {
setProjectAlerts(_filter(alerts, (a) => a.id !== id))
diff --git a/app/routes/projects.$id.alerts.create.tsx b/app/routes/projects.$pid.alerts.create.tsx
similarity index 100%
rename from app/routes/projects.$id.alerts.create.tsx
rename to app/routes/projects.$pid.alerts.create.tsx
diff --git a/public/locales/en.json b/public/locales/en.json
index 3125c3e92..b539da709 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -507,6 +507,8 @@
"create": "Create an alert",
"add": "Add Alert",
"delete": "Delete alert",
+ "noNameError": "Please enter a name for the alert.",
+ "queryValueError": "Please fill threshold and the query value has to be a number.",
"noIntegration": "You have not configured an integration yet. Create one in your <url>account settings</url>.",
"noNotification": "No notification channels set",
"lastTriggered": "Last Triggered",