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!

asking user for feedback when deleting account

Blue Mouseff6194547fff
diff --git a/app/api/index.ts b/app/api/index.ts
index 05f726f3d..8815d5aeb 100644
--- a/app/api/index.ts
+++ b/app/api/index.ts
@@ -150,9 +150,13 @@ export const signup = (data: {
throw new Error(errorsArray)
})
-export const deleteUser = () =>
+export const deleteUser = (deletionFeedback?: string) =>
api
- .delete('/user')
+ .delete('/user', {
+ data: {
+ feedback: deletionFeedback,
+ },
+ })
.then((response): {} => response.data)
.catch((error) => {
throw new Error(JSON.stringify(error.response.data))
diff --git a/app/pages/UserSettings/UserSettings.container.tsx b/app/pages/UserSettings/UserSettings.container.tsx
index 06759f618..11ffa5f69 100644
--- a/app/pages/UserSettings/UserSettings.container.tsx
+++ b/app/pages/UserSettings/UserSettings.container.tsx
@@ -31,6 +31,7 @@ const mapDispatchToProps = (dispatch: AppDispatch) => ({
},
onDelete: (
t: (key: string) => string,
+ deletionFeedback: string,
onSuccess: {
(): void;
},
@@ -46,6 +47,7 @@ const mapDispatchToProps = (dispatch: AppDispatch) => ({
trackCustom('ACCOUNT_DELETED')
onSuccess()
},
+ deletionFeedback,
t,
),
)
diff --git a/app/pages/UserSettings/UserSettings.tsx b/app/pages/UserSettings/UserSettings.tsx
index cf85cdd36..dd79e9a70 100644
--- a/app/pages/UserSettings/UserSettings.tsx
+++ b/app/pages/UserSettings/UserSettings.tsx
@@ -45,6 +45,7 @@ import Select from 'ui/Select'
import Checkbox from 'ui/Checkbox'
import PaidFeature from 'modals/PaidFeature'
import TimezonePicker from 'ui/TimezonePicker'
+import Textarea from 'ui/Textarea'
import Loader from 'ui/Loader'
import {
isValidEmail,
@@ -72,7 +73,7 @@ dayjs.extend(utc)
const timeFormatArray = _map(TimeFormat, (key) => key)
interface IProps {
- onDelete: (t: (key: string) => string, callback: () => void) => void,
+ onDelete: (t: (key: string) => string, deletionFeedback: string, callback: () => void) => void,
onDeleteProjectCache: () => void,
removeProject: (id: string) => void,
removeShareProject: (id: string) => void,
@@ -152,6 +153,7 @@ const UserSettings = ({
const translatedFrequencies: string[] = _map(reportFrequencies, (key) => t(`profileSettings.${key}`)) // useMemo(_map(reportFrequencies, (key) => t(`profileSettings.${key}`)), [t])
const translatedTimeFormat: string[] = _map(TimeFormat, (key) => t(`profileSettings.${key}`)) // useMemo(_map(TimeFormat, (key) => t(`profileSettings.${key}`)), [t])
const [settingUpdating, setSettingUpdating] = useState<boolean>(false)
+ const [deletionFeedback, setDeletionFeedback] = useState<string>('')
const copyTimerRef = useRef(null)
@@ -360,7 +362,7 @@ const UserSettings = ({
}
const _onDelete = () => {
- onDelete(t, () => {
+ onDelete(t, deletionFeedback, () => {
navigate(routes.main)
})
}
@@ -867,7 +869,10 @@ const UserSettings = ({
isOpened={showExportModal}
/>
<Modal
- onClose={() => setShowModal(false)}
+ onClose={() => {
+ setDeletionFeedback('')
+ setShowModal(false)
+ }}
onSubmit={() => {
setShowModal(false)
_onDelete()
@@ -877,7 +882,19 @@ const UserSettings = ({
title={t('profileSettings.qDelete')}
submitType='danger'
type='error'
- message={t('profileSettings.deactivateConfirmation')}
+ message={(
+ <>
+ {t('profileSettings.deactivateConfirmation')}
+ <Textarea
+ id='feedback'
+ className='mt-4'
+ placeholder={t('profileSettings.deletionFeedback')}
+ onChange={(e) => setDeletionFeedback(e.target.value)}
+ value={deletionFeedback}
+ label={t('profileSettings.deletionFeedbackLabel')}
+ />
+ </>
+ )}
isOpened={showModal}
/>
<Modal
diff --git a/app/redux/sagas/actions/index.ts b/app/redux/sagas/actions/index.ts
index bf735fb00..65acbf92e 100644
--- a/app/redux/sagas/actions/index.ts
+++ b/app/redux/sagas/actions/index.ts
@@ -94,11 +94,11 @@ const updateUserProfileAsync = (data: Partial<IUser>, callback = (item: any) =>
payload: { data, callback },
})
-const deleteAccountAsync = (errorCallback?: (e: string) => {}, successCallback?: (str?: string) => void, t?: (str: string) => {}) => {
+const deleteAccountAsync = (errorCallback?: (e: string) => {}, successCallback?: (str?: string) => void, deletionFeedback?: string, t?: (str: string) => {}) => {
return {
type: types.DELETE_ACCOUNT_ASYNC,
payload: {
- errorCallback, successCallback, t,
+ errorCallback, successCallback, t, deletionFeedback,
},
}
}
diff --git a/app/redux/sagas/auth/workers/deleteUserAccount.ts b/app/redux/sagas/auth/workers/deleteUserAccount.ts
index c873215c7..e5c42c349 100644
--- a/app/redux/sagas/auth/workers/deleteUserAccount.ts
+++ b/app/redux/sagas/auth/workers/deleteUserAccount.ts
@@ -4,15 +4,16 @@ import { authActions } from 'redux/reducers/auth'
import { alertsActions } from 'redux/reducers/alerts'
const { deleteUser } = require('api')
-export default function* deleteUserAccountWorker({ payload: { errorCallback, successCallback, t } }: {
+export default function* deleteUserAccountWorker({ payload: { errorCallback, successCallback, t, deletionFeedback } }: {
payload: {
errorCallback: (error: any) => void,
successCallback: () => void,
t: (key: string) => string,
+ deletionFeedback: string,
},
}) {
try {
- yield call(deleteUser)
+ yield call(deleteUser, deletionFeedback)
yield call(successCallback)
yield put(authActions.deleteAccountSuccess())
yield put(alertsActions.accountDeleted({
diff --git a/public/locales/en.json b/public/locales/en.json
index c07bd6de9..d1c23d17a 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -387,6 +387,8 @@
"requestExport": "Request data export",
"delete": "Delete account",
"deactivateConfirmation": "Are you sure you want to deactivate your account?\nAll of your data will be permanently removed from our servers forever.\nThis action cannot be undone.",
+ "deletionFeedbackLabel": "Why are you leaving? (optional)",
+ "deletionFeedback": "We're sad to see you go, could you please tell us why you're leaving so we could improve our service?",
"exportConfirmation": "As requested by Art. 20 of General Data Protection Regulation (GDPR) the you have the right to receive your personal data that we store. This report does not include events data per project.\nThe data report will be sent to your email address.\nNote: you can request the data export only once per two weeks.",
"dataExport": "Data export",
"aDelete": "Delete my account",