📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
saga to ts, update package json, update config, finish with integration redux
kruzhambus39ad0c0635a6
diff --git a/package.json b/package.jsonindex 765346806..a6f072cc3 100644--- a/package.json+++ b/package.json@@ -169,6 +169,7 @@},"devDependencies": {"@tailwindcss/typography": "^0.5.9",+ "@types/debug": "^4.1.7","@types/jest": "^29.5.0","@types/lodash": "^4.14.191","@types/node": "^18.15.3",diff --git a/src/App.jsx b/src/App.jsxindex 9f9d919ba..45a0964d1 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -21,10 +21,10 @@ import {isSelfhosted, // THEME_TYPE,} from 'redux/constants'import { getAccessToken } from 'utils/accessToken'-import { authActions } from 'redux/actions/auth'-import { errorsActions } from 'redux/actions/errors'-import { alertsActions } from 'redux/actions/alerts'-import UIActions from 'redux/actions/ui'+import authActions from 'redux/reducers/auth'+import errorsActions from 'redux/reducers/errors'+import alertsActions from 'redux/reducers/alerts'+import UIActions from 'redux/reducers/ui'import routes from 'routes'import { getRefreshToken } from 'utils/refreshToken'import { authMe } from './api'diff --git a/src/pages/CrashHandler/index.tsx b/src/pages/CrashHandler/index.tsxindex d3b161715..f5f1715ce 100644--- a/src/pages/CrashHandler/index.tsx+++ b/src/pages/CrashHandler/index.tsx@@ -35,7 +35,6 @@ class CrashHandler extends React.Component<CrashHandlerProps, CrashHandlerState>onCrashStackClick = () => {this.setState((prevState) => ({- // @ts-ignorecrashStackShown: !prevState.crashStackShown,}))}diff --git a/src/redux/sagas/ui/load_forecast.js b/src/redux/models/IOverallStats.tssimilarity index 100%rename from src/redux/sagas/ui/load_forecast.jsrename to src/redux/models/IOverallStats.tsdiff --git a/src/redux/models/IProject.ts b/src/redux/models/IProject.tsindex 15ba7d4d8..331cc5fe2 100644--- a/src/redux/models/IProject.ts+++ b/src/redux/models/IProject.ts@@ -1,10 +1,14 @@-export interface IOverall {+interface IOvervallObject {thisWeek: numberlastWeek: numberthisWeekUnique: numberlastWeekUnique: number}+export interface IOverall {+ [key: string]: IOvervallObject+}+export interface IUserShareProject {email: string}diff --git a/src/redux/models/IStats.ts b/src/redux/models/IStats.tsnew file mode 100644index 000000000..6caf0825d--- /dev/null+++ b/src/redux/models/IStats.ts@@ -0,0 +1,5 @@+export interface IStats {+ users: number+ projects: number+ pageviews: number+}diff --git a/src/redux/reducers/errors.ts b/src/redux/reducers/errors.tsindex 6e0fe15a2..58ce4ecce 100644--- a/src/redux/reducers/errors.ts+++ b/src/redux/reducers/errors.ts@@ -9,7 +9,7 @@ const initialState: IInitialState = {error: null,}-const errorsCreate = (state: IInitialState, { payload }: PayloadAction<{ message: string, type: string }>) => {+const errorsCreate = (state: IInitialState, { payload }: PayloadAction<{ message: string }>) => {state.error = payload.message}@@ -18,6 +18,7 @@ const errorsSlice = createSlice({initialState,reducers: {genericError: errorsCreate,+ setError: errorsCreate,loginFailed: errorsCreate,signUpFailed: errorsCreate,updateUserProfileFailed: errorsCreate,@@ -34,5 +35,5 @@ const errorsSlice = createSlice({},})-export const alertsActions = errorsSlice.actions+export const errorsActions = errorsSlice.actionsexport default errorsSlice.reducerdiff --git a/src/redux/reducers/ui/cache.ts b/src/redux/reducers/ui/cache.tsindex 61683a266..45291ec73 100644--- a/src/redux/reducers/ui/cache.ts+++ b/src/redux/reducers/ui/cache.ts@@ -84,21 +84,25 @@ const cacheSlice = createSlice({const {pid, period, timeBucket, rangeDate,} = payload- state.projectViewPrefs[pid] = rangeDate ? {+ const viewPrefs = rangeDate ? {period, timeBucket, rangeDate,} : {period, timeBucket,}+ window.localStorage.setItem(LS_VIEW_PREFS_SETTING, JSON.stringify(viewPrefs))+ state.projectViewPrefs[pid] = viewPrefs},setCaptchaProjectViewPrefs(state, { payload }: PayloadAction<{ pid: string, period: string, timeBucket: string, rangeDate: string }>) {const {pid, period, timeBucket, rangeDate,} = payload- state.captchaProjectsViewPrefs[pid] = rangeDate ? {+ const viewPrefs = rangeDate ? {period, timeBucket, rangeDate,} : {period, timeBucket,}+ window.localStorage.setItem(LS_CAPTCHA_VIEW_PREFS_SETTING, JSON.stringify(viewPrefs))+ state.captchaProjectsViewPrefs[pid] = viewPrefs},setProjectCachePerf(state, { payload }: PayloadAction<{ pid: string, key: string, data: any }>) {state.analyticsPerf[payload.pid][payload.key] = payload.datadiff --git a/src/redux/reducers/ui/misc.ts b/src/redux/reducers/ui/misc.tsindex 8a7bc7ebb..b4831a51e 100644--- a/src/redux/reducers/ui/misc.ts+++ b/src/redux/reducers/ui/misc.ts@@ -2,12 +2,8 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'import { LOW_EVENTS_WARNING } from 'redux/constants'import { setCookie } from 'utils/cookie'import { secondsTillNextMonth } from 'utils/generic'+import { IStats } from 'redux/models/IStats'-interface IStats {- users: number- projects: number- pageviews: number-}interface IInitialState {stats: IStatspaddle: any@@ -38,7 +34,7 @@ const miscSlice = createSlice({setPaddleLastEvent(state, { payload }: PayloadAction<any>) {state.paddle = { ...state.paddle, lastEvent: payload }},- setShowNoEventsLeft(state, { payload }: PayloadAction<boolean>) {+ setShowNoEventsLeftBanner(state, { payload }: PayloadAction<boolean>) {if (!payload) {const maxAge = secondsTillNextMonth() + 86400setCookie(LOW_EVENTS_WARNING, 1, maxAge)diff --git a/src/redux/reducers/ui/projects.ts b/src/redux/reducers/ui/projects.tsindex 61def7c91..cc30acb0a 100644--- a/src/redux/reducers/ui/projects.ts+++ b/src/redux/reducers/ui/projects.ts@@ -76,7 +76,7 @@ const projectsSlice = createSlice({reducers: {setProjects(state, { payload }: PayloadAction<{projects: IProject[] | ISharedProject[]- shared: boolean+ shared?: boolean}>) {if (payload.shared) {state.isLoadingShared = false@@ -102,17 +102,17 @@ const projectsSlice = createSlice({setTotalMonthlyEvents(state, { payload }: PayloadAction<number>) {state.totalMonthlyEvents = payload},- setTotal(state, { payload }: PayloadAction<{ total: number, shared: boolean }>) {+ setTotal(state, { payload }: PayloadAction<{ total: number, shared?: boolean }>) {if (payload.shared) {state.sharedTotal = payload.total} else {state.total = payload.total}},- setCaptchaProjectsTotal(state, { payload }: PayloadAction<number>) {+ setCaptchaTotal(state, { payload }: PayloadAction<number>) {state.captchaTotal = payload},- setCaptchaProjectsLoading(state, { payload }: PayloadAction<boolean>) {+ setCaptchaLoading(state, { payload }: PayloadAction<boolean>) {state.isLoadingCaptcha = payload},removeCaptchaProject(state, { payload }: PayloadAction<string>) {@@ -224,7 +224,7 @@ const projectsSlice = createSlice({state.total -= 1}},- setProjectsLoading(state, { payload }: PayloadAction<{ isLoading: boolean, shared: boolean }>) {+ setProjectsLoading(state, { payload }: PayloadAction<{ isLoading: boolean, shared?: boolean }>) {const { isLoading, shared = false } = payloadif (shared) {diff --git a/src/redux/sagas/actions/index.ts b/src/redux/sagas/actions/index.tsindex b51d31047..b68eb33c2 100644--- a/src/redux/sagas/actions/index.ts+++ b/src/redux/sagas/actions/index.ts@@ -1,30 +1,36 @@/* eslint-disable no-unused-vars */import types from 'redux/sagas/actions/types'-import { getRefreshToken } from 'utils/refreshToken'+import { getRefreshToken, removeRefreshToken } from 'utils/refreshToken'import { logoutApi } from 'api'+import { removeAccessToken } from 'utils/accessToken'+import { removeItem } from 'utils/localstorage'+import { LS_VIEW_PREFS_SETTING } from 'redux/constants'import { IUser } from '../../models/IUser'-const loadProjects = (take: string, skip: string) => ({+const loadProjects = (take?: number, skip?: number) => ({type: types.LOAD_PROJECTS,payload: { take, skip },})-const loadSharedProjects = (take: string, skip: string) => ({+const loadSharedProjects = (take?: number, skip?: number) => ({type: types.LOAD_SHARED_PROJECTS,payload: { take, skip },})-const loadProjectsCaptcha = (take: string, skip: string) => ({+const loadProjectsCaptcha = (take?: number, skip?: number) => ({type: types.LOAD_PROJECTS,payload: { take, skip, isCaptcha: true },})+const loadExtensions = () => ({type: types.LOAD_EXTENSIONS,})-const loadProjectAlerts = (take: string, skip: string) => ({++const loadProjectAlerts = (take?: number, skip?: number) => ({type: types.LOAD_PROJECT_ALERTS,payload: { take, skip },})+const loginAsync = (credentials: {email: string,password: string,@@ -38,7 +44,7 @@ const loginAsync = (credentials: {const signupAsync = (data: {email: string,password: string,-}, t: (string: string) => {}, callback = () => { }) => ({+}, t?: (string: string) => {}, callback = () => { }) => ({type: types.SIGNUP_ASYNC,payload: {data, callback, t,@@ -46,9 +52,8 @@ const signupAsync = (data: {})const emailVerifyAsync = (data: {- email: string,- code: string,-}, successfulCallback: () => {}, errorCallback: () => {}) => ({+ id: string,+}, successfulCallback?: () => {}, errorCallback?: () => {}) => ({type: types.EMAIL_VERIFY_ASYNC,payload: { data, successfulCallback, errorCallback },})@@ -58,7 +63,7 @@ const updateUserProfileAsync = (data: IUser, callback = () => { }) => ({payload: { data, callback },})-const deleteAccountAsync = (errorCallback: (e: string) => {}, successCallback: (str: string) => {}, t: (str: string) => {}) => {+const deleteAccountAsync = (errorCallback?: (e: string) => {}, successCallback?: (str: string) => {}, t?: (str: string) => {}) => {const refreshToken = getRefreshToken()logoutApi(refreshToken)@@ -70,6 +75,19 @@ const deleteAccountAsync = (errorCallback: (e: string) => {}, successCallback: (}}+const logout = (basedOn401Error: string) => {+ const refreshToken = getRefreshToken()+ logoutApi(refreshToken)+ removeAccessToken()+ removeRefreshToken()+ removeItem(LS_VIEW_PREFS_SETTING)++ return {+ type: types.LOGOUT,+ payload: { basedOn401Error },+ }+}+const sagaActions = {loadProjects,loadSharedProjects,@@ -81,6 +99,7 @@ const sagaActions = {emailVerifyAsync,updateUserProfileAsync,deleteAccountAsync,+ logout,}export default sagaActionsdiff --git a/src/redux/sagas/actions/types.ts b/src/redux/sagas/actions/types.tsindex 9d9424088..ceca6b19f 100644--- a/src/redux/sagas/actions/types.ts+++ b/src/redux/sagas/actions/types.ts@@ -8,6 +8,7 @@ const sagaTypes = {EMAIL_VERIFY_ASYNC: 'EMAIL_VERIFY_ASYNC',UPDATE_USER_PROFILE_ASYNC: 'UPDATE_USER_PROFILE_ASYNC',DELETE_ACCOUNT_ASYNC: 'DELETE_ACCOUNT_ASYNC',+ LOGOUT: 'LOGOUT',}export default sagaTypesdiff --git a/src/redux/sagas/auth/watchers/index.js b/src/redux/sagas/auth/watchers/index.tssimilarity index 63%rename from src/redux/sagas/auth/watchers/index.jsrename to src/redux/sagas/auth/watchers/index.tsindex 0e3cb93b7..ea83de867 100644--- a/src/redux/sagas/auth/watchers/index.js+++ b/src/redux/sagas/auth/watchers/index.ts@@ -1,34 +1,40 @@import { takeLatest, all, call } from 'redux-saga/effects'-import { types } from 'redux/actions/auth/types'import signIn from 'redux/sagas/auth/workers/signin'import signUp from 'redux/sagas/auth/workers/signup'import logout from 'redux/sagas/auth/workers/logout'import verifyEmail from 'redux/sagas/auth/workers/verifyEmail'import updateUserProfile from 'redux/sagas/auth/workers/updateUserProfile'import deleteUserAccount from 'redux/sagas/auth/workers/deleteUserAccount'+import sagaTypes from '../../actions/types'function* watchLogin() {- yield takeLatest(types.LOGIN_ASYNC, signIn)+ // @ts-ignore+ yield takeLatest(sagaTypes.LOGIN_ASYNC, signIn)}function* watchVerifyEmail() {- yield takeLatest(types.EMAIL_VERIFY_ASYNC, verifyEmail)+ // @ts-ignore+ yield takeLatest(sagaTypes.EMAIL_VERIFY_ASYNC, verifyEmail)}function* watchSignup() {- yield takeLatest(types.SIGNUP_ASYNC, signUp)+ // @ts-ignore+ yield takeLatest(sagaTypes.SIGNUP_ASYNC, signUp)}function* watchLogout() {- yield takeLatest(types.LOGOUT, logout)+ // @ts-ignore+ yield takeLatest(sagaTypes.LOGOUT, logout)}function* watchUpdateUserProfile() {- yield takeLatest(types.UPDATE_USER_PROFILE_ASYNC, updateUserProfile)+ // @ts-ignore+ yield takeLatest(sagaTypes.UPDATE_USER_PROFILE_ASYNC, updateUserProfile)}function* watchDeleteUserProfile() {- yield takeLatest(types.DELETE_ACCOUNT_ASYNC, deleteUserAccount)+ // @ts-ignore+ yield takeLatest(sagaTypes.DELETE_ACCOUNT_ASYNC, deleteUserAccount)}export default function* watchAuth() {diff --git a/src/redux/sagas/auth/workers/deleteUserAccount.js b/src/redux/sagas/auth/workers/deleteUserAccount.tssimilarity index 57%rename from src/redux/sagas/auth/workers/deleteUserAccount.jsrename to src/redux/sagas/auth/workers/deleteUserAccount.tsindex 1d1a09466..ed6f9224e 100644--- a/src/redux/sagas/auth/workers/deleteUserAccount.js+++ b/src/redux/sagas/auth/workers/deleteUserAccount.ts@@ -1,24 +1,35 @@import { call, put } from 'redux-saga/effects'-import { authActions } from 'redux/actions/auth'-import { alertsActions } from 'redux/actions/alerts'+import { authActions } from 'redux/reducers/auth'+import { alertsActions } from 'redux/reducers/alerts'import { deleteUser } from 'api'-export default function* deleteUserAccountWorker({ payload: { errorCallback, successCallback, t } }) {+export default function* deleteUserAccountWorker({ payload: { errorCallback, successCallback, t } }: {+ payload: {+ errorCallback: (error: any) => void,+ successCallback: () => void,+ t: (key: string) => string,+ },+}) {try {yield call(deleteUser)yield call(successCallback)yield put(authActions.deleteAccountSuccess())- yield put(alertsActions.accountDeleted(t('apiNotifications.accountDeleted')))+ yield put(alertsActions.accountDeleted({+ message: t('apiNotifications.accountDeleted'),+ type: 'success',+ }))} catch (error) {let messagetry {+ // @ts-ignoremessage = JSON.parse(error.message).message || 'somethingWentWrong'} catch (e) {message = 'somethingWentWrong'}+ // @ts-ignoreerrorCallback(t([`apiNotifications.${message}`, 'apiNotifications.somethingWentWrong']))} finally {yield put(authActions.finishLoading())diff --git a/src/redux/sagas/auth/workers/logout.js b/src/redux/sagas/auth/workers/logout.jsdeleted file mode 100644index 23b5adbad..000000000--- a/src/redux/sagas/auth/workers/logout.js+++ /dev/null@@ -1,18 +0,0 @@-import { call, put } from 'redux-saga/effects'-import Debug from 'debug'--import UIActions from 'redux/actions/ui'-import { getGeneralStats } from 'api'--const debug = Debug('swetrix:rx:s:logout')--export default function* logoutWorker({ payload: { basedOn401Error } = {} }) {- try {- if (!basedOn401Error) {- const stats = yield call(getGeneralStats)- yield put(UIActions.setGeneralStats(stats))- }- } catch (e) {- debug('Error while getting general stats data: %s', e)- }-}diff --git a/src/redux3/sagas/auth/workers/logout.js b/src/redux/sagas/auth/workers/logout.tssimilarity index 66%rename from src/redux3/sagas/auth/workers/logout.jsrename to src/redux/sagas/auth/workers/logout.tsindex 23b5adbad..41875fdcb 100644--- a/src/redux3/sagas/auth/workers/logout.js+++ b/src/redux/sagas/auth/workers/logout.ts@@ -1,15 +1,16 @@import { call, put } from 'redux-saga/effects'import Debug from 'debug'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import { getGeneralStats } from 'api'+import { IStats } from '../../../models/IStats'const debug = Debug('swetrix:rx:s:logout')-export default function* logoutWorker({ payload: { basedOn401Error } = {} }) {+export default function* logoutWorker({ payload: { basedOn401Error } }: { payload: { basedOn401Error: boolean } }) {try {if (!basedOn401Error) {- const stats = yield call(getGeneralStats)+ const stats: IStats = yield call(getGeneralStats)yield put(UIActions.setGeneralStats(stats))}} catch (e) {diff --git a/src/redux/sagas/auth/workers/signin.js b/src/redux/sagas/auth/workers/signin.jsdeleted file mode 100644index c568a645d..000000000--- a/src/redux/sagas/auth/workers/signin.js+++ /dev/null@@ -1,44 +0,0 @@-import { call, put } from 'redux-saga/effects'-import { authActions } from 'redux/actions/auth'-import { errorsActions } from 'redux/actions/errors'-import _isObject from 'lodash/isPlainObject'-import _omit from 'lodash/omit'--import UIActions from 'redux/actions/ui'-import { setAccessToken } from 'utils/accessToken'-import { login } from 'api'-import { setRefreshToken } from 'utils/refreshToken'--export default function* singinWorker({ payload: { credentials, callback } }) {- try {- const { dontRemember } = credentials- const {- user, accessToken, refreshToken,- } = yield call(login, _omit(credentials, ['dontRemember']))-- yield put(authActions.setDontRemember(dontRemember))-- if (user.isTwoFactorAuthenticationEnabled) {- yield call(setAccessToken, accessToken, true)- yield call(setRefreshToken, refreshToken)- yield put(authActions.updateUserData(user))- callback(false, true)- return- }-- yield put(authActions.loginSuccess(user))- yield call(setAccessToken, accessToken, dontRemember)- yield call(setRefreshToken, refreshToken)- yield put(UIActions.setThemeType(user.theme))- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- yield put(UIActions.loadProjectAlerts())- callback(true, false)- } catch (error) {- const err = _isObject(error) ? error.message : error- yield put(errorsActions.loginFailed(err || 'apiNotifications.somethingWentWrong'))- callback(false, false)- } finally {- yield put(authActions.finishLoading())- }-}diff --git a/src/redux3/sagas/auth/workers/signin.js b/src/redux/sagas/auth/workers/signin.tssimilarity index 66%rename from src/redux3/sagas/auth/workers/signin.jsrename to src/redux/sagas/auth/workers/signin.tsindex c568a645d..54670185f 100644--- a/src/redux3/sagas/auth/workers/signin.js+++ b/src/redux/sagas/auth/workers/signin.ts@@ -1,15 +1,25 @@import { call, put } from 'redux-saga/effects'-import { authActions } from 'redux/actions/auth'-import { errorsActions } from 'redux/actions/errors'+import { authActions } from 'redux/reducers/auth'+import { errorsActions } from 'redux/reducers/errors'import _isObject from 'lodash/isPlainObject'import _omit from 'lodash/omit'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import { setAccessToken } from 'utils/accessToken'import { login } from 'api'import { setRefreshToken } from 'utils/refreshToken'+import sagaActions from '../../actions/index'-export default function* singinWorker({ payload: { credentials, callback } }) {+export default function* singinWorker({ payload: { credentials, callback } }: {+ payload: {+ credentials: {+ email: string,+ password: string,+ dontRemember: boolean,+ },+ callback: (isSuccess: boolean, isTwoFactorAuthenticationEnabled: boolean) => void,+ },+}) {try {const { dontRemember } = credentialsconst {@@ -26,15 +36,16 @@ export default function* singinWorker({ payload: { credentials, callback } }) {return}- yield put(authActions.loginSuccess(user))+ yield put(authActions.loginSuccessful(user))yield call(setAccessToken, accessToken, dontRemember)yield call(setRefreshToken, refreshToken)yield put(UIActions.setThemeType(user.theme))- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- yield put(UIActions.loadProjectAlerts())+ yield put(sagaActions.loadProjects())+ yield put(sagaActions.loadSharedProjects())+ yield put(sagaActions.loadProjectAlerts())callback(true, false)} catch (error) {+ // @ts-ignoreconst err = _isObject(error) ? error.message : erroryield put(errorsActions.loginFailed(err || 'apiNotifications.somethingWentWrong'))callback(false, false)diff --git a/src/redux/sagas/auth/workers/signup.js b/src/redux/sagas/auth/workers/signup.jsdeleted file mode 100644index 58b100196..000000000--- a/src/redux/sagas/auth/workers/signup.js+++ /dev/null@@ -1,35 +0,0 @@-import { call, put } from 'redux-saga/effects'-import { authActions } from 'redux/actions/auth'-import { errorsActions } from 'redux/actions/errors'-import _omit from 'lodash/omit'--import UIActions from 'redux/actions/ui'-import { setAccessToken } from 'utils/accessToken'-import { signup } from 'api'-import { setRefreshToken } from 'utils/refreshToken'--export default function* signupWorder({ payload: { data: rawData, callback } }) {- try {- const { repeat, ...data } = rawData- const { dontRemember } = data- const {- user, accessToken, refreshToken, // theme,- } = yield call(signup, _omit(data, ['dontRemember']))-- yield put(authActions.signupSuccess(user))- yield call(setAccessToken, accessToken, dontRemember)- yield call(setRefreshToken, refreshToken)- yield put(authActions.setDontRemember(dontRemember))- // yield put(UIActions.setThemeType(response.theme))- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- yield put(UIActions.loadProjectAlerts())- callback(true)- } catch (error) {- const message = error.message || (typeof error === 'string' ? error : error[0])- yield put(errorsActions.signupFailed(message || 'apiNotifications.somethingWentWrong'))- callback(false)- } finally {- yield put(authActions.finishLoading())- }-}diff --git a/src/redux3/sagas/auth/workers/signup.js b/src/redux/sagas/auth/workers/signup.tssimilarity index 62%rename from src/redux3/sagas/auth/workers/signup.jsrename to src/redux/sagas/auth/workers/signup.tsindex 58b100196..bfb88e3f4 100644--- a/src/redux3/sagas/auth/workers/signup.js+++ b/src/redux/sagas/auth/workers/signup.ts@@ -1,14 +1,24 @@import { call, put } from 'redux-saga/effects'-import { authActions } from 'redux/actions/auth'-import { errorsActions } from 'redux/actions/errors'+import { authActions } from 'redux/reducers/auth'+import { errorsActions } from 'redux/reducers/errors'import _omit from 'lodash/omit'-import UIActions from 'redux/actions/ui'import { setAccessToken } from 'utils/accessToken'import { signup } from 'api'import { setRefreshToken } from 'utils/refreshToken'+import sagaActions from '../../actions'-export default function* signupWorder({ payload: { data: rawData, callback } }) {+export default function* signupWorder({ payload: { data: rawData, callback } }: {+ payload: {+ data: {+ email: string,+ password: string+ repeat: string+ dontRemember: boolean+ },+ callback: (isSuccess: boolean) => void+ }+}) {try {const { repeat, ...data } = rawDataconst { dontRemember } = data@@ -16,17 +26,19 @@ export default function* signupWorder({ payload: { data: rawData, callback } })user, accessToken, refreshToken, // theme,} = yield call(signup, _omit(data, ['dontRemember']))- yield put(authActions.signupSuccess(user))+ yield put(authActions.signupUpSuccessful(user))yield call(setAccessToken, accessToken, dontRemember)yield call(setRefreshToken, refreshToken)yield put(authActions.setDontRemember(dontRemember))// yield put(UIActions.setThemeType(response.theme))- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- yield put(UIActions.loadProjectAlerts())+ yield put(sagaActions.loadProjects())+ yield put(sagaActions.loadSharedProjects())+ yield put(sagaActions.loadProjectAlerts())callback(true)- } catch (error) {+ } catch (error: unknown) {+ // @ts-ignoreconst message = error.message || (typeof error === 'string' ? error : error[0])+ // @ts-ignoreyield put(errorsActions.signupFailed(message || 'apiNotifications.somethingWentWrong'))callback(false)} finally {diff --git a/src/redux/sagas/auth/workers/updateUserProfile.js b/src/redux/sagas/auth/workers/updateUserProfile.jsdeleted file mode 100644index aada1db8d..000000000--- a/src/redux/sagas/auth/workers/updateUserProfile.js+++ /dev/null@@ -1,20 +0,0 @@-import { call, put } from 'redux-saga/effects'--import { authActions } from 'redux/actions/auth'-import { errorsActions } from 'redux/actions/errors'-import { changeUserDetails } from 'api'--export default function* updateUserProfileWorker({ payload: { data, callback } }) {- let isSuccess = false- try {- const user = yield call(changeUserDetails, data)-- yield put(authActions.updateProfileSuccess(user))- isSuccess = true- } catch (error) {- yield put(errorsActions.updateProfileFailed(error.message || (typeof error === 'string' ? error : error[0])))- } finally {- yield put(authActions.finishLoading())- callback(isSuccess)- }-}diff --git a/src/redux/sagas/auth/workers/updateUserProfile.ts b/src/redux/sagas/auth/workers/updateUserProfile.tsnew file mode 100644index 000000000..303d1f3b2--- /dev/null+++ b/src/redux/sagas/auth/workers/updateUserProfile.ts@@ -0,0 +1,30 @@+import { call, put } from 'redux-saga/effects'++import { authActions } from 'redux/reducers/auth'+import { errorsActions } from 'redux/reducers/errors'+import { changeUserDetails } from 'api'+import { IUser } from '../../../models/IUser'++export default function* updateUserProfileWorker({ payload: { data, callback } }: {+ payload: {+ data: IUser+ callback: (isSuccess: boolean) => void+ }+}) {+ let isSuccess = false+ try {+ const user: IUser = yield call(changeUserDetails, data)++ yield put(authActions.updateUserProfileSuccess(user))+ isSuccess = true+ } catch (e: unknown) {+ const error = e as { message: string } | string[] | string+ yield put(errorsActions.updateUserProfileFailed({+ // @ts-ignore+ message: error?.message || (typeof error === 'string' ? error : error[0]),+ }))+ } finally {+ yield put(authActions.finishLoading())+ callback(isSuccess)+ }+}diff --git a/src/redux/sagas/auth/workers/verifyEmail.js b/src/redux/sagas/auth/workers/verifyEmail.tssimilarity index 52%rename from src/redux/sagas/auth/workers/verifyEmail.jsrename to src/redux/sagas/auth/workers/verifyEmail.tsindex 5ca09fdb8..706a1d2b7 100644--- a/src/redux/sagas/auth/workers/verifyEmail.js+++ b/src/redux/sagas/auth/workers/verifyEmail.ts@@ -1,12 +1,21 @@import { call, put } from 'redux-saga/effects'-import { authActions } from 'redux/actions/auth'+import { authActions } from 'redux/reducers/auth'import { verifyEmail } from 'api'-export default function* verifyEmailWorker({ payload: { data, successfulCallback, errorCallback } }) {+export default function* verifyEmailWorker({ payload: { data, successfulCallback, errorCallback } }: {+ payload: {+ data: {+ id: string,+ },+ successfulCallback: () => void,+ errorCallback: (error: any) => void,+ },+}) {try {+ // @ts-ignoreyield call(verifyEmail, data)- yield put(authActions.emailVerifySuccess())+ yield put(authActions.emailVerifySuccessful())successfulCallback()} catch (error) {errorCallback(error)diff --git a/src/redux/sagas/index.js b/src/redux/sagas/index.tssimilarity index 100%rename from src/redux/sagas/index.jsrename to src/redux/sagas/index.tsdiff --git a/src/redux/sagas/ui/index.js b/src/redux/sagas/ui/index.jsdeleted file mode 100644index c07f6281d..000000000--- a/src/redux/sagas/ui/index.js+++ /dev/null@@ -1,31 +0,0 @@-import { takeEvery, fork, takeLatest } from 'redux-saga/effects'-import { types } from '../../actions/ui/types'-import { types as authTypes } from '../../actions/auth/types'--import loadProjects from './load_projects'-import initialise from './initialise'-import liveVisitors from './worker_live_visitors'-import generalStats from './worker_general_stats'-import setProjectViewPrefs from './set_project_view_prefs'-import isEventsAvailable from './worker_is_events_available'-import shareVerify from './share_verify'-import loadExtensions from './load_extensions'-import logout from './logout'-import loadSharedProjects from './load_shared_projects'-import loadProjectAlerts from './load_alerts'--function* mainUISaga() {- yield fork(initialise)- yield fork(liveVisitors)- yield fork(isEventsAvailable)- yield fork(generalStats)- yield takeEvery(types.SET_PROJECT_VIEW_PREFS, setProjectViewPrefs)- yield takeEvery(types.LOAD_PROJECTS, loadProjects)- yield takeEvery(types.LOAD_SHARED_PROJECTS, loadSharedProjects)- yield takeEvery(types.LOAD_EXTENSIONS, loadExtensions)- yield takeEvery(authTypes.LOGOUT, logout)- yield takeLatest(types.SHARE_VERIFY_ASYNC, shareVerify)- yield takeLatest(types.LOAD_PROJECT_ALERTS, loadProjectAlerts)-}--export default mainUISagadiff --git a/src/redux3/sagas/ui/index.js b/src/redux/sagas/ui/index.tssimilarity index 54%rename from src/redux3/sagas/ui/index.jsrename to src/redux/sagas/ui/index.tsindex c07f6281d..082fd521b 100644--- a/src/redux3/sagas/ui/index.js+++ b/src/redux/sagas/ui/index.ts@@ -1,12 +1,10 @@import { takeEvery, fork, takeLatest } from 'redux-saga/effects'-import { types } from '../../actions/ui/types'-import { types as authTypes } from '../../actions/auth/types'+import sagaTypes from '../actions/types'import loadProjects from './load_projects'import initialise from './initialise'import liveVisitors from './worker_live_visitors'import generalStats from './worker_general_stats'-import setProjectViewPrefs from './set_project_view_prefs'import isEventsAvailable from './worker_is_events_available'import shareVerify from './share_verify'import loadExtensions from './load_extensions'@@ -19,13 +17,17 @@ function* mainUISaga() {yield fork(liveVisitors)yield fork(isEventsAvailable)yield fork(generalStats)- yield takeEvery(types.SET_PROJECT_VIEW_PREFS, setProjectViewPrefs)- yield takeEvery(types.LOAD_PROJECTS, loadProjects)- yield takeEvery(types.LOAD_SHARED_PROJECTS, loadSharedProjects)- yield takeEvery(types.LOAD_EXTENSIONS, loadExtensions)- yield takeEvery(authTypes.LOGOUT, logout)- yield takeLatest(types.SHARE_VERIFY_ASYNC, shareVerify)- yield takeLatest(types.LOAD_PROJECT_ALERTS, loadProjectAlerts)+ // @ts-ignore+ yield takeEvery(sagaTypes.LOAD_PROJECTS, loadProjects)+ // @ts-ignore+ yield takeEvery(sagaTypes.LOAD_SHARED_PROJECTS, loadSharedProjects)+ yield takeEvery(sagaTypes.LOAD_EXTENSIONS, loadExtensions)+ // @ts-ignore+ yield takeEvery(sagaTypes.LOGOUT, logout)+ // @ts-ignore+ yield takeLatest(sagaTypes.SHARE_VERIFY_ASYNC, shareVerify)+ // @ts-ignore+ yield takeLatest(sagaTypes.LOAD_PROJECT_ALERTS, loadProjectAlerts)}export default mainUISagadiff --git a/src/redux/sagas/ui/initialise.js b/src/redux/sagas/ui/initialise.jsdeleted file mode 100644index ce9ac621e..000000000--- a/src/redux/sagas/ui/initialise.js+++ /dev/null@@ -1,29 +0,0 @@-import { put, call } from 'redux-saga/effects'-import Debug from 'debug'--import { getAccessToken } from 'utils/accessToken'-import { getRefreshToken } from 'utils/refreshToken'-import { getLastPost } from 'api/blog'-import UIActions from 'redux/actions/ui'--const debug = Debug('swetrix:rx:s:initialise')--export default function* initialise() {- try {- const token = yield call(getAccessToken)- const refreshToken = yield call(getRefreshToken)-- if (token && refreshToken) {- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- yield put(UIActions.loadProjectsCaptcha())- yield put(UIActions.loadExtensions())- yield put(UIActions.loadProjectAlerts())- }-- const lastBlogPost = yield call(getLastPost)- yield put(UIActions.setLastBlogPost(lastBlogPost))- } catch (e) {- debug('An error occured whilst initialising: %s', e)- }-}diff --git a/src/redux/sagas/ui/initialise.ts b/src/redux/sagas/ui/initialise.tsnew file mode 100644index 000000000..d266f77be--- /dev/null+++ b/src/redux/sagas/ui/initialise.ts@@ -0,0 +1,33 @@+import { put, call } from 'redux-saga/effects'+import Debug from 'debug'++import { getAccessToken } from 'utils/accessToken'+import { getRefreshToken } from 'utils/refreshToken'+import { getLastPost } from 'api/blog'+import UIActions from 'redux/reducers/ui'+import sagaActions from '../actions'++const debug = Debug('swetrix:rx:s:initialise')++export default function* initialise() {+ try {+ const token: string = yield call(getAccessToken)+ const refreshToken: string = yield call(getRefreshToken)++ if (token && refreshToken) {+ yield put(sagaActions.loadProjects())+ yield put(sagaActions.loadSharedProjects())+ yield put(sagaActions.loadProjectsCaptcha())+ yield put(sagaActions.loadExtensions())+ yield put(sagaActions.loadProjectAlerts())+ }++ const lastBlogPost: {+ title: string,+ url_path: string,+ } = yield call(getLastPost)+ yield put(UIActions.setLastBlogPost(lastBlogPost))+ } catch (e) {+ debug('An error occured whilst initialising: %s', e)+ }+}diff --git a/src/redux/sagas/ui/load_alerts.js b/src/redux/sagas/ui/load_alerts.jsdeleted file mode 100644index fea0b9010..000000000--- a/src/redux/sagas/ui/load_alerts.js+++ /dev/null@@ -1,26 +0,0 @@-import { put, call } from 'redux-saga/effects'-import Debug from 'debug'-import _isString from 'lodash/isString'-import UIActions from 'redux/actions/ui'-import { errorsActions } from 'redux/actions/errors'-import { DEFAULT_ALERTS_TAKE } from 'redux/constants'-import { getAlerts } from 'api'--const debug = Debug('swetrix:rx:s:load-extensions')--export default function* loadProjectAlerts({ payload: { take = DEFAULT_ALERTS_TAKE, skip = 0 } }) {- try {- yield put(UIActions.setProjectAlertsLoading(true))- const { results, total, page_total: pageTotal } = yield call(getAlerts, take, skip)-- yield put(UIActions.setProjectAlerts(results))- yield put(UIActions.setProjectAlertsTotal(total, pageTotal))- } catch ({ message }) {- if (_isString(message)) {- yield put(errorsActions.setError(message))- }- debug('failed to load extensions: %s', message)- } finally {- yield put(UIActions.setProjectAlertsLoading(false))- }-}diff --git a/src/redux3/sagas/ui/load_alerts.js b/src/redux/sagas/ui/load_alerts.tssimilarity index 68%rename from src/redux3/sagas/ui/load_alerts.jsrename to src/redux/sagas/ui/load_alerts.tsindex fea0b9010..3a015a02e 100644--- a/src/redux3/sagas/ui/load_alerts.js+++ b/src/redux/sagas/ui/load_alerts.ts@@ -1,8 +1,8 @@import { put, call } from 'redux-saga/effects'import Debug from 'debug'import _isString from 'lodash/isString'-import UIActions from 'redux/actions/ui'-import { errorsActions } from 'redux/actions/errors'+import UIActions from 'redux/reducers/ui'+import { errorsActions } from 'redux/reducers/errors'import { DEFAULT_ALERTS_TAKE } from 'redux/constants'import { getAlerts } from 'api'@@ -14,10 +14,16 @@ export default function* loadProjectAlerts({ payload: { take = DEFAULT_ALERTS_TAconst { results, total, page_total: pageTotal } = yield call(getAlerts, take, skip)yield put(UIActions.setProjectAlerts(results))- yield put(UIActions.setProjectAlertsTotal(total, pageTotal))- } catch ({ message }) {+ yield put(UIActions.setProjectAlertsTotal({+ total,+ pageTotal,+ }))+ } catch (e: unknown) {+ const { message } = e as { message: string }if (_isString(message)) {- yield put(errorsActions.setError(message))+ yield put(errorsActions.setError({+ message,+ }))}debug('failed to load extensions: %s', message)} finally {diff --git a/src/redux/sagas/ui/load_extensions.js b/src/redux/sagas/ui/load_extensions.jsdeleted file mode 100644index 1d49b5672..000000000--- a/src/redux/sagas/ui/load_extensions.js+++ /dev/null@@ -1,23 +0,0 @@-import { put, call } from 'redux-saga/effects'-import Debug from 'debug'--import UIActions from 'redux/actions/ui'--import {- getInstalledExtensions,-} from '../../../api'--const debug = Debug('swetrix:rx:s:load-extensions')--export default function* loadExtensions() {- try {- const { extensions } = yield call(getInstalledExtensions)-- yield put(UIActions.setExtensions(extensions))- } catch ({ message }) {- // if (_isString(message)) {- // yield put(UIActions.setProjectsError(message))- // }- debug('failed to load extensions: %s', message)- }-}diff --git a/src/redux3/sagas/ui/load_extensions.js b/src/redux/sagas/ui/load_extensions.tssimilarity index 81%rename from src/redux3/sagas/ui/load_extensions.jsrename to src/redux/sagas/ui/load_extensions.tsindex 1d49b5672..664275398 100644--- a/src/redux3/sagas/ui/load_extensions.js+++ b/src/redux/sagas/ui/load_extensions.ts@@ -1,7 +1,7 @@import { put, call } from 'redux-saga/effects'import Debug from 'debug'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import {getInstalledExtensions,@@ -14,7 +14,8 @@ export default function* loadExtensions() {const { extensions } = yield call(getInstalledExtensions)yield put(UIActions.setExtensions(extensions))- } catch ({ message }) {+ } catch (e: unknown) {+ const { message } = e as { message: string }// if (_isString(message)) {// yield put(UIActions.setProjectsError(message))// }diff --git a/src/redux/sagas/ui/load_projects.js b/src/redux/sagas/ui/load_projects.jsdeleted file mode 100644index 74bac29a4..000000000--- a/src/redux/sagas/ui/load_projects.js+++ /dev/null@@ -1,67 +0,0 @@-import { put, call } from 'redux-saga/effects'-import _map from 'lodash/map'-import _isString from 'lodash/isString'-import Debug from 'debug'--import UIActions from 'redux/actions/ui'--import { ENTRIES_PER_PAGE_DASHBOARD } from 'redux/constants'-import {- getProjects, getOverallStats, getLiveVisitors, getOverallStatsCaptcha,-} from '../../../api'--const debug = Debug('swetrix:rx:s:load-projects')--export default function* loadProjects({ payload: { take = ENTRIES_PER_PAGE_DASHBOARD, skip = 0, isCaptcha = false } }) {- try {- if (isCaptcha) {- yield put(UIActions.setCaptchaLoading(true))- } else {- yield put(UIActions.setProjectsLoading(true))- }-- let {- // eslint-disable-next-line prefer-const- results, totalMonthlyEvents, total,- } = yield call(getProjects, take, skip, isCaptcha)-- const pids = _map(results, result => result.id)- let overall-- if (isCaptcha) {- try {- overall = yield call(getOverallStatsCaptcha, pids)- } catch (e) {- debug('failed to overall stats: %s', e)- }- } else {- try {- overall = yield call(getOverallStats, pids)- } catch (e) {- debug('failed to overall stats: %s', e)- }- }-- results = _map(results, res => ({- ...res,- overall: overall?.[res.id],- }))-- if (isCaptcha) {- yield put(UIActions.setCaptchaProjects(results))- yield put(UIActions.setTotalCaptcha(total))- } else {- yield put(UIActions.setProjects(results))- yield put(UIActions.setTotalMonthlyEvents(totalMonthlyEvents))- yield put(UIActions.setTotal(total))- }-- const liveStats = yield call(getLiveVisitors, pids)- yield put(UIActions.setLiveStats(liveStats))- } catch ({ message }) {- if (_isString(message)) {- yield put(UIActions.setProjectsError(message))- }- debug('failed to load projects: %s', message)- }-}diff --git a/src/redux3/sagas/ui/load_projects.js b/src/redux/sagas/ui/load_projects.tssimilarity index 76%rename from src/redux3/sagas/ui/load_projects.jsrename to src/redux/sagas/ui/load_projects.tsindex 74bac29a4..aaec70612 100644--- a/src/redux3/sagas/ui/load_projects.js+++ b/src/redux/sagas/ui/load_projects.ts@@ -3,9 +3,10 @@ import _map from 'lodash/map'import _isString from 'lodash/isString'import Debug from 'debug'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import { ENTRIES_PER_PAGE_DASHBOARD } from 'redux/constants'+import { IOverall } from 'redux/models/IProject'import {getProjects, getOverallStats, getLiveVisitors, getOverallStatsCaptcha,} from '../../../api'@@ -17,7 +18,10 @@ export default function* loadProjects({ payload: { take = ENTRIES_PER_PAGE_DASHBif (isCaptcha) {yield put(UIActions.setCaptchaLoading(true))} else {- yield put(UIActions.setProjectsLoading(true))+ yield put(UIActions.setProjectsLoading({+ isLoading: true,+ shared: false,+ }))}let {@@ -26,7 +30,8 @@ export default function* loadProjects({ payload: { take = ENTRIES_PER_PAGE_DASHB} = yield call(getProjects, take, skip, isCaptcha)const pids = _map(results, result => result.id)- let overall++ let overall: IOverallif (isCaptcha) {try {@@ -49,16 +54,20 @@ export default function* loadProjects({ payload: { take = ENTRIES_PER_PAGE_DASHBif (isCaptcha) {yield put(UIActions.setCaptchaProjects(results))- yield put(UIActions.setTotalCaptcha(total))+ yield put(UIActions.setCaptchaTotal(total))} else {yield put(UIActions.setProjects(results))yield put(UIActions.setTotalMonthlyEvents(totalMonthlyEvents))yield put(UIActions.setTotal(total))}- const liveStats = yield call(getLiveVisitors, pids)- yield put(UIActions.setLiveStats(liveStats))- } catch ({ message }) {+ const liveStats: any[] = yield call(getLiveVisitors, pids)+ yield put(UIActions.setLiveStats({+ data: liveStats,+ shared: false,+ }))+ } catch (e: unknown) {+ const { message } = e as { message: string }if (_isString(message)) {yield put(UIActions.setProjectsError(message))}diff --git a/src/redux/sagas/ui/load_shared_projects.js b/src/redux/sagas/ui/load_shared_projects.tssimilarity index 68%rename from src/redux/sagas/ui/load_shared_projects.jsrename to src/redux/sagas/ui/load_shared_projects.tsindex 494c7a14a..b879cab2b 100644--- a/src/redux/sagas/ui/load_shared_projects.js+++ b/src/redux/sagas/ui/load_shared_projects.ts@@ -3,9 +3,10 @@ import _map from 'lodash/map'import _isString from 'lodash/isString'import Debug from 'debug'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import { ENTRIES_PER_PAGE_DASHBOARD } from 'redux/constants'+import { IOverall } from 'redux/models/IProject'import {getSharedProjects, getOverallStats, getLiveVisitors,} from '../../../api'@@ -14,7 +15,10 @@ const debug = Debug('swetrix:rx:s:load-projects')export default function* loadSharedProjects({ payload: { take = ENTRIES_PER_PAGE_DASHBOARD, skip = 0 } }) {try {- yield put(UIActions.setProjectsLoading(true, true))+ yield put(UIActions.setProjectsLoading({+ isLoading: true,+ shared: true,+ }))let {// eslint-disable-next-line prefer-const@@ -36,7 +40,7 @@ export default function* loadSharedProjects({ payload: { take = ENTRIES_PER_PAGE})const pids = _map(projectsWithShared, ({ project }) => project.id)- let overall+ let overall: IOveralltry {overall = yield call(getOverallStats, pids)@@ -52,12 +56,22 @@ export default function* loadSharedProjects({ payload: { take = ENTRIES_PER_PAGE},}))- yield put(UIActions.setProjects(results, true))- yield put(UIActions.setTotal(total, true))+ yield put(UIActions.setProjects({+ projects: results,+ shared: true,+ }))+ yield put(UIActions.setTotal({+ total,+ shared: true,+ }))- const liveStats = yield call(getLiveVisitors, pids)- yield put(UIActions.setLiveStats(liveStats, true))- } catch ({ message }) {+ const liveStats: any[] = yield call(getLiveVisitors, pids)+ yield put(UIActions.setLiveStats({+ data: liveStats,+ shared: true,+ }))+ } catch (e: unknown) {+ const { message } = e as { message: string }if (_isString(message)) {yield put(UIActions.setProjectsError(message))}diff --git a/src/redux/sagas/ui/logout.js b/src/redux/sagas/ui/logout.jsdeleted file mode 100644index cb661f35c..000000000--- a/src/redux/sagas/ui/logout.js+++ /dev/null@@ -1,11 +0,0 @@-import { put } from 'redux-saga/effects'--import UIActions from 'redux/actions/ui'--export default function* logout() {- yield put(UIActions.setProjects([]))- yield put(UIActions.setProjects([], true))- yield put(UIActions.setTotal(0))- yield put(UIActions.setTotal(0, true))- yield put(UIActions.deleteProjectCache())-}diff --git a/src/redux/sagas/ui/logout.ts b/src/redux/sagas/ui/logout.tsnew file mode 100644index 000000000..3f07d2792--- /dev/null+++ b/src/redux/sagas/ui/logout.ts@@ -0,0 +1,25 @@+import { put } from 'redux-saga/effects'++import UIActions from 'redux/reducers/ui'++export default function* logout() {+ yield put(UIActions.setProjects({+ projects: [],+ }))+ yield put(UIActions.setProjects({+ projects: [],+ shared: true,+ }))+ yield put(UIActions.setTotal({+ total: 0,+ }))+ yield put(UIActions.setTotal({+ total: 0,+ shared: true,+ }))+ yield put(UIActions.deleteProjectCache({+ pid: '',+ period: '',+ timeBucket: '',+ }))+}diff --git a/src/redux/sagas/ui/set_project_view_prefs.js b/src/redux/sagas/ui/set_project_view_prefs.jsdeleted file mode 100644index 7bdc3cfa5..000000000--- a/src/redux/sagas/ui/set_project_view_prefs.js+++ /dev/null@@ -1,21 +0,0 @@-import { LS_VIEW_PREFS_SETTING } from 'redux/constants'-import { getInitialViewPrefs } from 'redux/reducers/ui/cache'--export default function setProjectViewPrefs({- payload: {- pid, period, timeBucket, rangeDate,- },-}) {- if (typeof window !== 'undefined' && window.localStorage) {- const viewPrefs = {- ...getInitialViewPrefs(),- [pid]: rangeDate ? {- period, timeBucket, rangeDate,- } : {- period, timeBucket,- },- }-- window.localStorage.setItem(LS_VIEW_PREFS_SETTING, JSON.stringify(viewPrefs))- }-}diff --git a/src/redux/sagas/ui/share_verify.js b/src/redux/sagas/ui/share_verify.jsdeleted file mode 100644index 4bd036917..000000000--- a/src/redux/sagas/ui/share_verify.js+++ /dev/null@@ -1,15 +0,0 @@-import { call, put } from 'redux-saga/effects'--import UIActions from 'redux/actions/ui'-import { verifyShare } from 'api'--export default function* shareVerify({ payload: { data, successfulCallback, errorCallback } }) {- try {- yield call(verifyShare, data)- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- successfulCallback()- } catch (error) {- errorCallback(error)- }-}diff --git a/src/redux/sagas/ui/share_verify.ts b/src/redux/sagas/ui/share_verify.tsnew file mode 100644index 000000000..66bb9deae--- /dev/null+++ b/src/redux/sagas/ui/share_verify.ts@@ -0,0 +1,25 @@+import { call, put } from 'redux-saga/effects'++import { verifyShare } from 'api'+import sagaActions from '../actions'++export default function* shareVerify({ payload: { data, successfulCallback, errorCallback } }: {+ payload: {+ data: {+ path: string,+ id: string,+ },+ successfulCallback: () => void,+ errorCallback: (error: any) => void,+ },+}) {+ try {+ // @ts-ignore+ yield call(verifyShare, data)+ yield put(sagaActions.loadProjects())+ yield put(sagaActions.loadSharedProjects())+ successfulCallback()+ } catch (error) {+ errorCallback(error)+ }+}diff --git a/src/redux/sagas/ui/worker_general_stats.js b/src/redux/sagas/ui/worker_general_stats.jsdeleted file mode 100644index e3984f2bb..000000000--- a/src/redux/sagas/ui/worker_general_stats.js+++ /dev/null@@ -1,32 +0,0 @@-import {- put, call, delay, select,-} from 'redux-saga/effects'-import Debug from 'debug'--import { getGeneralStats } from 'api'-import UIActions from 'redux/actions/ui'-import { GENERAL_STATS_UPDATE_INTERVAL } from 'redux/constants'--const debug = Debug('swetrix:rx:s:general-stats')--const NOT_AUTHED_INTERVAL = 5000 // 5 seconds--export default function* generalStats() {- while (true) {- const isAuthenticated = yield select(state => state.auth.authenticated)- if (isAuthenticated) {- yield delay(NOT_AUTHED_INTERVAL)- continue- }-- try {- const stats = yield call(getGeneralStats)-- yield put(UIActions.setGeneralStats(stats))- } catch (e) {- debug('Error while getting general stats data: %s', e)- }-- yield delay(GENERAL_STATS_UPDATE_INTERVAL)- }-}diff --git a/src/redux3/sagas/ui/worker_general_stats.js b/src/redux/sagas/ui/worker_general_stats.tssimilarity index 73%rename from src/redux3/sagas/ui/worker_general_stats.jsrename to src/redux/sagas/ui/worker_general_stats.tsindex e3984f2bb..a661f9dc4 100644--- a/src/redux3/sagas/ui/worker_general_stats.js+++ b/src/redux/sagas/ui/worker_general_stats.ts@@ -4,8 +4,9 @@ import {import Debug from 'debug'import { getGeneralStats } from 'api'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import { GENERAL_STATS_UPDATE_INTERVAL } from 'redux/constants'+import { IStats } from 'redux/models/IStats'const debug = Debug('swetrix:rx:s:general-stats')@@ -13,14 +14,14 @@ const NOT_AUTHED_INTERVAL = 5000 // 5 secondsexport default function* generalStats() {while (true) {- const isAuthenticated = yield select(state => state.auth.authenticated)+ const isAuthenticated: boolean = yield select(state => state.auth.authenticated)if (isAuthenticated) {yield delay(NOT_AUTHED_INTERVAL)continue}try {- const stats = yield call(getGeneralStats)+ const stats: IStats = yield call(getGeneralStats)yield put(UIActions.setGeneralStats(stats))} catch (e) {diff --git a/src/redux/sagas/ui/worker_is_events_available.js b/src/redux/sagas/ui/worker_is_events_available.jsdeleted file mode 100644index e88058dba..000000000--- a/src/redux/sagas/ui/worker_is_events_available.js+++ /dev/null@@ -1,51 +0,0 @@-import { put, delay, select } from 'redux-saga/effects'-import _isNull from 'lodash/isNull'--import UIActions from 'redux/actions/ui'-import { SHOW_BANNER_AT_PERC, LOW_EVENTS_WARNING } from 'redux/constants'-import { getCookie } from 'utils/cookie'--const NOT_AUTHED_INTERVAL = 1000 // 1 second-const NO_DATA_YET = 1000 // 1 second-const DATA_REQUEST_ATTEMPTS = 20--export default function* checkEventsAvailable() {- const lowEvents = getCookie(LOW_EVENTS_WARNING)-- if (lowEvents) {- return- }-- let dataRequests = 0-- while (true) {- if (dataRequests > DATA_REQUEST_ATTEMPTS) {- return- }-- const isAuthenticated = yield select(state => state.auth.authenticated)-- if (!isAuthenticated) {- yield delay(NOT_AUTHED_INTERVAL)- continue- }-- const totalMonthlyEvents = yield select(state => state.ui.projects.totalMonthlyEvents)-- if (_isNull(totalMonthlyEvents)) {- dataRequests++- yield delay(NO_DATA_YET)- continue- }-- const maxEventsCount = yield select(state => state.auth.user.maxEventsCount)-- const eventsUsedPercentage = (totalMonthlyEvents * 100) / maxEventsCount-- if (eventsUsedPercentage >= SHOW_BANNER_AT_PERC) {- yield put(UIActions.setShowNoEventsLeftBanner(true))- }-- return- }-}diff --git a/src/redux3/sagas/ui/worker_is_events_available.js b/src/redux/sagas/ui/worker_is_events_available.tssimilarity index 75%rename from src/redux3/sagas/ui/worker_is_events_available.jsrename to src/redux/sagas/ui/worker_is_events_available.tsindex e88058dba..4cd48741c 100644--- a/src/redux3/sagas/ui/worker_is_events_available.js+++ b/src/redux/sagas/ui/worker_is_events_available.ts@@ -1,7 +1,7 @@import { put, delay, select } from 'redux-saga/effects'import _isNull from 'lodash/isNull'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import { SHOW_BANNER_AT_PERC, LOW_EVENTS_WARNING } from 'redux/constants'import { getCookie } from 'utils/cookie'@@ -23,14 +23,14 @@ export default function* checkEventsAvailable() {return}- const isAuthenticated = yield select(state => state.auth.authenticated)+ const isAuthenticated: boolean = yield select(state => state.auth.authenticated)if (!isAuthenticated) {yield delay(NOT_AUTHED_INTERVAL)continue}- const totalMonthlyEvents = yield select(state => state.ui.projects.totalMonthlyEvents)+ const totalMonthlyEvents: number | null = yield select(state => state.ui.projects.totalMonthlyEvents)if (_isNull(totalMonthlyEvents)) {dataRequests++@@ -38,7 +38,7 @@ export default function* checkEventsAvailable() {continue}- const maxEventsCount = yield select(state => state.auth.user.maxEventsCount)+ const maxEventsCount: number = yield select(state => state.auth.user.maxEventsCount)const eventsUsedPercentage = (totalMonthlyEvents * 100) / maxEventsCountdiff --git a/src/redux/sagas/ui/worker_live_visitors.js b/src/redux/sagas/ui/worker_live_visitors.jsdeleted file mode 100644index ba999818d..000000000--- a/src/redux/sagas/ui/worker_live_visitors.js+++ /dev/null@@ -1,50 +0,0 @@-import {- put, call, delay, select,-} from 'redux-saga/effects'-import _map from 'lodash/map'-import _filter from 'lodash/filter'-import _isEmpty from 'lodash/isEmpty'--import { getLiveVisitors } from 'api'-import UIActions from 'redux/actions/ui'-import { LIVE_VISITORS_UPDATE_INTERVAL, tabForSharedProject } from 'redux/constants'--export default function* liveVisitors() {- while (true) {- yield delay(LIVE_VISITORS_UPDATE_INTERVAL)- const tab = yield select(state => state.ui.projects.dashboardTabs)-- if (tabForSharedProject === tab) {- const sharedProjects = yield select(state => state.ui.projects.sharedProjects)-- if (_isEmpty(sharedProjects)) {- continue- }-- const pids = _map(_filter(sharedProjects, ({ project }) => !project.uiHidden), item => item.project.id)-- if (_isEmpty(pids)) {- continue- }-- const liveStats = yield call(getLiveVisitors, pids)-- yield put(UIActions.setLiveStats(liveStats, true))- } else {- const projects = yield select(state => state.ui.projects.projects)- if (_isEmpty(projects)) {- continue- }-- const pids = _map(_filter(projects, ({ uiHidden }) => !uiHidden), project => project.id)-- if (_isEmpty(pids)) {- continue- }-- const liveStats = yield call(getLiveVisitors, pids)-- yield put(UIActions.setLiveStats(liveStats))- }- }-}diff --git a/src/redux3/sagas/ui/worker_live_visitors.js b/src/redux/sagas/ui/worker_live_visitors.tssimilarity index 54%rename from src/redux3/sagas/ui/worker_live_visitors.jsrename to src/redux/sagas/ui/worker_live_visitors.tsindex ba999818d..3760edf96 100644--- a/src/redux3/sagas/ui/worker_live_visitors.js+++ b/src/redux/sagas/ui/worker_live_visitors.ts@@ -6,16 +6,18 @@ import _filter from 'lodash/filter'import _isEmpty from 'lodash/isEmpty'import { getLiveVisitors } from 'api'-import UIActions from 'redux/actions/ui'+import UIActions from 'redux/reducers/ui'import { LIVE_VISITORS_UPDATE_INTERVAL, tabForSharedProject } from 'redux/constants'+import { ISharedProject } from '../../models/ISharedProject'+import { IProject } from '../../models/IProject'export default function* liveVisitors() {while (true) {yield delay(LIVE_VISITORS_UPDATE_INTERVAL)- const tab = yield select(state => state.ui.projects.dashboardTabs)+ const tab: string = yield select(state => state.ui.projects.dashboardTabs)if (tabForSharedProject === tab) {- const sharedProjects = yield select(state => state.ui.projects.sharedProjects)+ const sharedProjects: ISharedProject[] = yield select(state => state.ui.projects.sharedProjects)if (_isEmpty(sharedProjects)) {continue@@ -27,11 +29,14 @@ export default function* liveVisitors() {continue}- const liveStats = yield call(getLiveVisitors, pids)+ const liveStats: any[] = yield call(getLiveVisitors, pids)- yield put(UIActions.setLiveStats(liveStats, true))+ yield put(UIActions.setLiveStats({+ data: liveStats,+ shared: true,+ }))} else {- const projects = yield select(state => state.ui.projects.projects)+ const projects: IProject[] = yield select(state => state.ui.projects.projects)if (_isEmpty(projects)) {continue}@@ -42,9 +47,12 @@ export default function* liveVisitors() {continue}- const liveStats = yield call(getLiveVisitors, pids)+ const liveStats: any[] = yield call(getLiveVisitors, pids)- yield put(UIActions.setLiveStats(liveStats))+ yield put(UIActions.setLiveStats({+ data: liveStats,+ shared: false,+ }))}}}diff --git a/src/redux/store/index.ts b/src/redux/store/index.tsindex 9ccd990e1..85b2ec5a0 100644--- a/src/redux/store/index.ts+++ b/src/redux/store/index.ts@@ -2,23 +2,37 @@ import { combineReducers, configureStore } from '@reduxjs/toolkit'import createSagaMiddleware from 'redux-saga'import rootSaga from '../sagas'import authSlice from '../reducers/auth'+import errorsSlice from '../reducers/errors'+import alertsSlice from '../reducers/alerts'+import miscSlice from '../reducers/ui/misc'+import projectsSlice from '../reducers/ui/projects'+import alertsProjectsSlice from '../reducers/ui/alerts'+import themeSlice from '../reducers/ui/theme'+import cacheSlice from '../reducers/ui/cache'const rootReducer = combineReducers({auth: authSlice,+ errors: errorsSlice,+ alerts: alertsSlice,+ ui: combineReducers({+ misc: miscSlice,+ projects: projectsSlice,+ alerts: alertsProjectsSlice,+ theme: themeSlice,+ cache: cacheSlice,+ }),})const sagaMiddleware = createSagaMiddleware()-export const setupStore = () => {- return configureStore({- reducer: rootReducer,- middleware: (getDefaultMiddleware: any) => getDefaultMiddleware()- .concat(sagaMiddleware),- })-}--export type RootState = ReturnType<typeof rootReducer>-export type AppStore = ReturnType<typeof setupStore>-export type AppDispatch = AppStore['dispatch']+export const store = configureStore({+ reducer: rootReducer,+ middleware: (getDefaultMiddleware: any) => getDefaultMiddleware()+ .concat(sagaMiddleware),+})sagaMiddleware.run(rootSaga)++export type RootState = ReturnType<typeof rootReducer>+export type AppStore = ReturnType<typeof store.getState>+export type AppDispatch = typeof store.dispatchdiff --git a/src/redux3/actions/alerts/index.js b/src/redux3/actions/alerts/index.jsdeleted file mode 100644index 961147868..000000000--- a/src/redux3/actions/alerts/index.js+++ /dev/null@@ -1,79 +0,0 @@-import { types } from './types'--export const alertsActions = {- accountDeleted(message, type = 'success') {- return {- type: types.ACCOUNT_DELETED,- payload: { message, type },- }- },-- accountUpdated(message, type = 'success') {- return {- type: types.ACCOUNT_UPDATED,- payload: { message, type },- }- },-- newPassword(message, type = 'success') {- return {- type: types.NEW_PASSWORD,- payload: { message, type },- }- },-- newProject(message, type = 'success') {- return {- type: types.CREATE_NEW_PROJECT_SUCCESS,- payload: { message, type },- }- },-- projectDeleted(message, type = 'success') {- return {- type: types.CREATE_NEW_PROJECT_SUCCESS,- payload: { message, type },- }- },-- roleUpdated(message, type = 'success') {- return {- type: types.ROLE_UPDATED,- payload: { message, type },- }- },-- inviteUser(message, type = 'success') {- return {- type: types.INVITE_USER,- payload: { message, type },- }- },-- removeUser(message, type = 'success') {- return {- type: types.REMOVE_USER,- payload: { message, type },- }- },-- userSharedUpdate(message, type = 'success') {- return {- type: types.USER_SHARED_UPDATE,- payload: { message, type },- }- },-- generateAlerts(message, type = 'success') {- return {- type: types.GENERATE_ALERTS,- payload: { message, type },- }- },-- clearAlerts() {- return {- type: types.CLEAR_ALERTS,- }- },-}diff --git a/src/redux3/actions/alerts/types.js b/src/redux3/actions/alerts/types.jsdeleted file mode 100644index b7e7391b4..000000000--- a/src/redux3/actions/alerts/types.js+++ /dev/null@@ -1,17 +0,0 @@-export const types = {- ACCOUNT_DELETED: 'ALERT_ACCOUNT_DELETED',- ACCOUNT_UPDATED: 'ALERT_ACCOUNT_UPDATED',- NEW_PASSWORD: 'ALERT_NEW_PASSWORD',-- // Projects- CREATE_NEW_PROJECT_SUCCESS: 'ALERT_CREATE_NEW_PROJECT_SUCCESS',- DELETE_PROJECT_SUCCESS: 'ALERT_DELETE_PROJECT_SUCCESS',- ROLE_UPDATED: 'ALERT_ROLE_UPDATED',- INVITE_USER: 'ALERT_INVITE_USER',- REMOVE_USER: 'ALERT_REMOVE_USER',- USER_SHARED_UPDATE: 'ALERT_USER_SHARED_UPDATE',- GENERATE_ALERTS: 'ALERT_GENERATE_ALERTS',-- // Common- CLEAR_ALERTS: 'CLEAR_ALERTS',-}diff --git a/src/redux3/actions/auth/index.js b/src/redux3/actions/auth/index.jsdeleted file mode 100644index 09035b499..000000000--- a/src/redux3/actions/auth/index.js+++ /dev/null@@ -1,164 +0,0 @@-import { removeItem } from 'utils/localstorage'-import { removeAccessToken } from 'utils/accessToken'-import { getRefreshToken, removeRefreshToken } from 'utils/refreshToken'-import { logoutApi } from 'api'-import { LS_VIEW_PREFS_SETTING } from 'redux/constants'-import { types } from './types'--export const authActions = {- loginSuccess(user) {- return {- type: types.LOGIN_SUCCESSFUL,- payload: { user },- }- },-- emailVerifySuccess() {- return {- type: types.EMAIL_VERIFY_SUCCESSFUL,- }- },-- signupSuccess(user) {- return {- type: types.SIGNUP_UP_SUCCESSFUL,- payload: { user },- }- },-- updateProfileSuccess(user) {- return {- type: types.UPDATE_USER_PROFILE_SUCCESS,- payload: { user },- }- },-- logout(basedOn401Error) {- const refreshToken = getRefreshToken()- logoutApi(refreshToken)- removeAccessToken()- removeRefreshToken()- removeItem(LS_VIEW_PREFS_SETTING)-- return {- type: types.LOGOUT,- payload: { basedOn401Error },- }- },-- clearErrors() {- return {- type: types.CLEAR_ERRORS,- }- },-- savePath(path) {- return {- type: types.SAVE_PATH,- payload: { path },- }- },-- setDontRemember(dontRemember) {- return {- type: types.SET_DONT_REMEMBER,- payload: { dontRemember },- }- },-- updateUserData(data) {- return {- type: types.UPDATE_USER_DATA,- payload: { data },- }- },-- deleteAccountSuccess() {- removeAccessToken()- removeRefreshToken()- removeItem('user_info')-- return {- type: types.DELETE_ACCOUNT_SUCCESS,- }- },-- finishLoading() {- return {- type: types.FINISH_LOADING,- }- },-- // Asynchronous- loginAsync(credentials, callback = () => { }) {- return {- type: types.LOGIN_ASYNC,- payload: {- credentials, callback,- },- }- },-- signupAsync(data, t, callback = () => { }) {- return {- type: types.SIGNUP_ASYNC,- payload: {- data, callback, t,- },- }- },-- emailVerifyAsync(data, successfulCallback, errorCallback) {- return {- type: types.EMAIL_VERIFY_ASYNC,- payload: { data, successfulCallback, errorCallback },- }- },-- updateUserProfileAsync(data, callback = () => { }) {- return {- type: types.UPDATE_USER_PROFILE_ASYNC,- payload: { data, callback },- }- },-- deleteAccountAsync(errorCallback, successCallback, t) {- const refreshToken = getRefreshToken()- logoutApi(refreshToken)-- return {- type: types.DELETE_ACCOUNT_ASYNC,- payload: {- errorCallback, successCallback, t,- },- }- },-- deleteShareProject(id) {- return {- type: types.DELETE_SHARE_PROJECT,- payload: { id },- }- },-- setUserShareData(data, id) {- return {- type: types.SET_USER_SHARE_DATA,- payload: { data, id },- }- },-- setApiKey(apiKey) {- return {- type: types.SET_API_KEY,- payload: { apiKey },- }- },-- setUser(user) {- return {- type: types.SET_USER,- payload: { user },- }- },-}diff --git a/src/redux3/actions/auth/types.js b/src/redux3/actions/auth/types.jsdeleted file mode 100644index 7568e3aa4..000000000--- a/src/redux3/actions/auth/types.js+++ /dev/null@@ -1,25 +0,0 @@-export const types = {- // Synchronous- FINISH_LOADING: 'FINISH_LOADING',- LOGIN_SUCCESSFUL: 'LOGIN_SUCCESSFUL',- EMAIL_VERIFY_SUCCESSFUL: 'EMAIL_VERIFY_SUCCESSFUL',- EMAIL_VERIFY_FAILED: 'EMAIL_VERIFY_FAILED',- SIGNUP_UP_SUCCESSFUL: 'SIGNUP_UP_SUCCESSFUL',- UPDATE_USER_PROFILE_SUCCESS: 'UPDATE_USER_PROFILE_SUCCESS',- LOGOUT: 'LOGOUT',- SAVE_PATH: 'SAVE_PATH',- DELETE_ACCOUNT_SUCCESS: 'DELETE_ACCOUNT_SUCCESS',- DELETE_SHARE_PROJECT: 'DELETE_SHARE_PROJECT',- SET_USER_SHARE_DATA: 'SET_USER_SHARE_DATA',- SET_DONT_REMEMBER: 'SET_DONT_REMEMBER',- UPDATE_USER_DATA: 'UPDATE_USER_DATA',- SET_API_KEY: 'SET_API_KEY',- SET_USER: 'SET_USER',-- // Asynchronous- LOGIN_ASYNC: 'LOGIN_ASYNC',- SIGNUP_ASYNC: 'SIGNUP_ASYNC',- EMAIL_VERIFY_ASYNC: 'EMAIL_VERIFY_ASYNC',- UPDATE_USER_PROFILE_ASYNC: 'UPDATE_USER_PROFILE_ASYNC',- DELETE_ACCOUNT_ASYNC: 'DELETE_ACCOUNT_ASYNC',-}diff --git a/src/redux3/actions/errors/index.js b/src/redux3/actions/errors/index.jsdeleted file mode 100644index 36d277575..000000000--- a/src/redux3/actions/errors/index.js+++ /dev/null@@ -1,87 +0,0 @@-import { types } from './types'--export const errorsActions = {- // Authorisation- loginFailed(error) {- return {- type: types.LOGIN_FAILED,- payload: { error },- }- },-- signupFailed(error) {- return {- type: types.SIGN_UP_FAILED,- payload: { error },- }- },-- createNewPasswordFailed(error) {- return {- type: types.CREATE_NEW_PASSWORD_FAILED,- payload: { error },- }- },-- updateProfileFailed(error) {- return {- type: types.UPDATE_USER_PROFILE_FAILED,- payload: { error },- }- },-- deleteAccountFailed(error) {- return {- type: types.DELETE_ACCOUNT_FAILED,- payload: { error },- }- },-- createNewProjectFailed(error) {- return {- type: types.CREATE_NEW_PROJECT_FAILED,- payload: { error },- }- },-- updateProjectFailed(error) {- return {- type: types.UPDATE_PROJECT_FAILED,- payload: { error },- }- },-- deleteProjectFailed(error) {- return {- type: types.DELETE_PROJECT_FAILED,- payload: { error },- }- },-- GDPRExportFailed(error) {- return {- type: types.GDPR_EXPORT_FAILED,- payload: { error },- }- },-- sharedProjectFailed(error) {- return {- type: types.SHARED_PROJECT_FAILED,- payload: { error },- }- },-- genericError(error) {- return {- type: types.GENERIC_ERROR,- payload: { error },- }- },-- clearErrors() {- return {- type: types.CLEAR_ERRORS,- }- },-}diff --git a/src/redux3/actions/errors/types.js b/src/redux3/actions/errors/types.jsdeleted file mode 100644index 6f869de88..000000000--- a/src/redux3/actions/errors/types.js+++ /dev/null@@ -1,22 +0,0 @@-export const types = {- // Authorisation- LOGIN_FAILED: 'LOGIN_FAILED',- SIGN_UP_FAILED: 'SIGN_UP_FAILED',- UPDATE_USER_PROFILE_FAILED: 'UPDATE_USER_PROFILE_FAILED',- CREATE_NEW_PASSWORD_FAILED: 'CREATE_NEW_PASSWORD_FAILED',- DELETE_ACCOUNT_FAILED: 'DELETE_ACCOUNT_FAILED',-- // User- GDPR_EXPORT_FAILED: 'GDPR_EXPORT_FAILED',-- // Projects- CREATE_NEW_PROJECT_FAILED: 'CREATE_NEW_PROJECT_FAILED',- UPDATE_PROJECT_FAILED: 'UPDATE_PROJECT_FAILED',- DELETE_PROJECT_FAILED: 'DELETE_PROJECT_FAILED',- SHARED_PROJECT_FAILED: 'SHARED_PROJECT_FAILED',-- GENERIC_ERROR: 'GENERIC_ERROR',-- // Common- CLEAR_ERRORS: 'CLEAR_ERRORS',-}diff --git a/src/redux3/actions/ui/index.js b/src/redux3/actions/ui/index.jsdeleted file mode 100644index e17d78020..000000000--- a/src/redux3/actions/ui/index.js+++ /dev/null@@ -1,333 +0,0 @@-import { types } from './types'--const loadProjects = (take, skip) => ({- type: types.LOAD_PROJECTS,- payload: { take, skip },-})--const loadSharedProjects = (take, skip) => ({- type: types.LOAD_SHARED_PROJECTS,- payload: { take, skip },-})--const loadProjectsCaptcha = (take, skip) => ({- type: types.LOAD_PROJECTS,- payload: { take, skip, isCaptcha: true },-})--const setProjects = (projects, shared) => ({- type: types.SET_PROJECTS,- payload: {- projects,- shared,- },-})--const setExtensions = (extensions) => ({- type: types.SET_EXTENSIONS,- payload: {- extensions,- },-})--const loadExtensions = () => ({- type: types.LOAD_EXTENSIONS,-})--const setTotalMonthlyEvents = (totalMonthlyEvents) => ({- type: types.SET_TOTAL_MONTHLY_EVENTS,- payload: {- totalMonthlyEvents,- },-})--const setTotal = (total, shared) => ({- type: types.SET_TOTAL,- payload: {- total,- shared,- },-})--const setDashboardPaginationPage = (page) => ({- type: types.SET_DASHBOARD_PAGINATION_PAGE,- payload: {- page,- },-})--const setDashboardPaginationPageShared = (page) => ({- type: types.SET_DASHBOARD_PAGINATION_PAGE_SHARED,- payload: {- page,- },-})--const setShowNoEventsLeftBanner = (showNoEventsLeftBanner) => ({- type: types.SET_SHOW_NO_EVENTS_LEFT,- payload: {- showNoEventsLeftBanner,- },-})--const setLiveStats = (data, shared) => ({- type: types.SET_LIVE_STATS,- payload: {- data,- shared,- },-})--const setLiveStatsForProject = (id, count, shared) => ({- type: types.SET_LIVE_STATS_PROJECT,- payload: {- id, count, shared,- },-})--const setPublicProject = (project, shared) => ({- type: types.SET_PUBLIC_PROJECT,- payload: {- project,- shared,- },-})--const removeProject = (pid, shared) => ({- type: types.REMOVE_PROJECT,- payload: {- pid,- shared,- },-})--const setProjectsError = (error) => ({- type: types.SET_PROJECTS_ERROR,- payload: {- error,- },-})--const setProjectsLoading = (isLoading, shared) => ({- type: types.SET_PROJECTS_LOADING,- payload: {- isLoading,- shared,- },-})--const setProjectCache = (pid, data, key) => ({- type: types.SET_PROJECT_CACHE,- payload: {- pid, data, key,- },-})--const setCaptchaProjectCache = (pid, data, key) => ({- type: types.SET_CAPTCHA_PROJECT_CACHE,- payload: {- pid, data, key,- },-})--const setProjectCachePerf = (pid, data, key) => ({- type: types.SET_PROJECT_CACHE_PERF,- payload: {- pid, data, key,- },-})--const setProjectForcastCache = (pid, data, key) => ({- type: types.SET_PROJECT_FORECAST_CACHE,- payload: {- pid, data, key,- },-})--const deleteProjectCache = (pid, period, timeBucket) => ({- type: types.DELETE_PROJECT_CACHE,- payload: {- pid, period, timeBucket,- },-})--const deleteCaptchaProjectCache = (pid, period, timeBucket) => ({- type: types.DELETE_CAPTCHA_PROJECT_CACHE,- payload: {- pid, period, timeBucket,- },-})--const deleteProjectCachePerf = (pid, period, timeBucket) => ({- type: types.DELETE_PROJECT_CACHE_PERF,- payload: {- pid, period, timeBucket,- },-})--const setProjectViewPrefs = (pid, period, timeBucket, rangeDate) => ({- type: types.SET_PROJECT_VIEW_PREFS,- payload: {- pid, period, timeBucket, rangeDate,- },-})--const setCaptchaProjectsViewPrefs = (pid, period, timeBucket, rangeDate) => ({- type: types.SET_CAPTCHA_PROJECTS_VIEW_PREFS,- payload: {- pid, period, timeBucket, rangeDate,- },-})--const setTheme = (theme) => ({- type: types.SET_THEME,- payload: {- theme,- },-})--const setGeneralStats = (stats) => ({- type: types.SET_GENERAL_STATS,- payload: {- stats,- },-})--const setPaddleLastEvent = (event) => ({- type: types.SET_PADDLE_LAST_EVENT,- payload: {- event,- },-})--const setProjectsShareData = (data, id, shared) => ({- type: types.SET_PROJECTS_SHARE_DATA,- payload: {- data,- id,- shared,- },-})--const shareVerifyAsync = (data, successfulCallback, errorCallback) => ({- type: types.SHARE_VERIFY_ASYNC,- payload: { data, successfulCallback, errorCallback },-})--const setDashboardTabs = (tab) => ({- type: types.SET_DASHBOARD_TABS,- payload: { tab },-})--const setLastBlogPost = (lastBlogPost) => ({- type: types.SET_LAST_BLOG_POST,- payload: { lastBlogPost },-})--const setThemeType = (theme) => ({- type: types.SET_THEME_TYPE,- payload: { theme },-})--const setProjectTab = (tab) => ({- type: types.SET_PROJECT_TAB,- payload: { tab },-})--const setProjectAlerts = (alerts) => ({- type: types.SET_PROJECT_ALERTS,- payload: { alerts },-})--const setProjectAlertsTotal = (total, pageTotal) => ({- type: types.SET_PROJECT_ALERTS_TOTAL,- payload: { total, pageTotal },-})--const setProjectAlertsLoading = (loading) => ({- type: types.SET_PROJECT_ALERTS_LOADING,- payload: { loading },-})--const loadProjectAlerts = (take, skip) => ({- type: types.LOAD_PROJECT_ALERTS,- payload: { take, skip },-})--const setCaptchaProjects = (captchaProjects) => ({- type: types.SET_CAPTCHA_PROJECTS,- payload: { captchaProjects },-})--const removeCaptchProject = (pid) => ({- type: types.REMOVE_CAPTCHA_PROJECT,- payload: { pid },-})--const setTotalCaptcha = (total) => ({- type: types.SET_CAPTCHA_PROJECTS_TOTAL,- payload: { total },-})--const setDashboardPaginationPageCaptcha = (page) => ({- type: types.SET_DASHBOARD_PAGINATION_PAGE_CAPTCHA,- payload: {- page,- },-})--const setCaptchaLoading = (isLoading) => ({- type: types.SET_CAPTCHA_PROJECTS_LOADING,- payload: {- isLoading,- },-})--const UIActions = {- loadProjects,- loadSharedProjects,- setProjects,- setProjectsError,- setProjectsLoading,- removeProject,- setProjectCache,- deleteProjectCache,- setProjectViewPrefs,- setPublicProject,- setLiveStatsForProject,- setLiveStats,- setTheme,- setGeneralStats,- setPaddleLastEvent,- setTotalMonthlyEvents,- setDashboardPaginationPage,- setDashboardPaginationPageShared,- setTotal,- setShowNoEventsLeftBanner,- setProjectsShareData,- shareVerifyAsync,- setDashboardTabs,- setExtensions,- loadExtensions,- setLastBlogPost,- setThemeType,- setProjectCachePerf,- deleteProjectCachePerf,- setProjectTab,- setProjectAlerts,- setProjectAlertsTotal,- setProjectAlertsLoading,- loadProjectAlerts,- setProjectForcastCache,- setCaptchaProjects,- setTotalCaptcha,- setDashboardPaginationPageCaptcha,- loadProjectsCaptcha,- setCaptchaLoading,- removeCaptchProject,- setCaptchaProjectsViewPrefs,- setCaptchaProjectCache,- deleteCaptchaProjectCache,-}--export default UIActionsdiff --git a/src/redux3/actions/ui/types.js b/src/redux3/actions/ui/types.jsdeleted file mode 100644index e0a76db40..000000000--- a/src/redux3/actions/ui/types.js+++ /dev/null@@ -1,45 +0,0 @@-export const types = {- LOAD_PROJECTS: 'UI_LOAD_PROJECTS',- SET_PROJECTS_ERROR: 'UI_SET_PROJECTS_ERROR',- SET_PROJECTS_LOADING: 'UI_SET_PROJECTS_LOADING',- REMOVE_PROJECT: 'UI_REMOVE_PROJECT',- SET_PROJECT_CACHE: 'UI_SET_PROJECT_CACHE',- SET_CAPTCHA_PROJECT_CACHE: 'UI_SET_CAPTCHA_PROJECT_CACHE',- DELETE_PROJECT_CACHE: 'UI_DELETE_PROJECT_CACHE',- DELETE_CAPTCHA_PROJECT_CACHE: 'UI_DELETE_CAPTCHA_PROJECT_CACHE',- SET_PROJECT_VIEW_PREFS: 'UI_SET_PROJECT_VIEW_PREFS',- SET_CAPTCHA_PROJECTS_VIEW_PREFS: 'UI_SET_CAPTCHA_PROJECTS_VIEW_PREFS',- SET_PROJECTS: 'UI_SET_PROJECTS',- SET_EXTENSIONS: 'UI_SET_EXTENSIONS',- LOAD_EXTENSIONS: 'UI_LOAD_EXTENSIONS',- SET_LIVE_STATS: 'UI_SET_LIVE_STATS',- SET_LIVE_STATS_PROJECT: 'UI_SET_LIVE_STATS_PROJECT',- SET_PUBLIC_PROJECT: 'UI_SET_PUBLIC_PROJECT',- SET_THEME: 'UI_SET_THEME',- SET_GENERAL_STATS: 'UI_SET_GENERAL_STATS',- SET_PADDLE_LAST_EVENT: 'UI_SET_PADDLE_LAST_EVENT',- SET_TOTAL_MONTHLY_EVENTS: 'UI_SET_TOTAL_MONTHLY_EVENTS',- SET_TOTAL: 'UI_SET_TOTAL',- SET_DASHBOARD_PAGINATION_PAGE: 'UI_SET_DASHBOARD_PAGINATION_PAGE',- SET_DASHBOARD_PAGINATION_PAGE_SHARED: 'UI_SET_DASHBOARD_PAGINATION_PAGE_SHARED',- SET_SHOW_NO_EVENTS_LEFT: 'UI_SET_SHOW_NO_EVENTS_LEFT',- SET_LAST_BLOG_POST: 'UI_SET_LAST_BLOG_POST',- SET_PROJECTS_SHARE_DATA: 'UI_SET_PROJECTS_SHARE_DATA',- SHARE_VERIFY_ASYNC: 'UI_SHARE_VERIFY_ASYNC',- LOAD_SHARED_PROJECTS: 'UI_LOAD_SHARED_PROJECTS',- SET_DASHBOARD_TABS: 'UI_SET_DASHBOARD_TABS',- SET_THEME_TYPE: 'UI_SET_THEME_TYPE',- SET_PROJECT_CACHE_PERF: 'UI_SET_PROJECT_CACHE_PERF',- DELETE_PROJECT_CACHE_PERF: 'UI_DELETE_PROJECT_CACHE_PERF',- SET_PROJECT_TAB: 'UI_SET_PROJECT_TAB',- LOAD_PROJECT_ALERTS: 'UI_LOAD_PROJECT_ALERTS',- SET_PROJECT_ALERTS: 'UI_SET_PROJECT_ALERTS',- SET_PROJECT_ALERTS_TOTAL: 'UI_SET_PROJECT_ALERTS_TOTAL',- SET_PROJECT_ALERTS_LOADING: 'UI_SET_PROJECT_ALERTS_LOADING',- SET_PROJECT_FORECAST_CACHE: 'UI_SET_PROJECT_FORECAST_CACHE',- SET_CAPTCHA_PROJECTS: 'UI_SET_CAPTCHA_PROJECTS',- SET_CAPTCHA_PROJECTS_TOTAL: 'UI_SET_CAPTCHA_PROJECTS_TOTAL',- SET_DASHBOARD_PAGINATION_PAGE_CAPTCHA: 'UI_SET_DASHBOARD_PAGINATION_PAGE_CAPTCHA',- SET_CAPTCHA_PROJECTS_LOADING: 'UI_SET_CAPTCHA_PROJECTS_LOADING',- REMOVE_CAPTCHA_PROJECT: 'UI_REMOVE_CAPTCHA_PROJECT',-}diff --git a/src/redux3/constants/index.ts b/src/redux3/constants/index.tsdeleted file mode 100644index 2647efe70..000000000--- a/src/redux3/constants/index.ts+++ /dev/null@@ -1,349 +0,0 @@-const getCustomLabel = (dates: Date[], t: Function) => {- if (dates) {- const from = dates[0].toLocaleDateString()- const to = dates[1].toLocaleDateString()-- if (from === to) {- return from- }-- return `${from} - ${to}`- }-- return t('project.custom')-}--export const FORECAST_MAX_MAPPING = {- hour: 72,- day: 21,- week: 21,- month: 12,-}--export const tbPeriodPairs = (t: Function, tbs: String[] | null, dates: Date[]) => [{- label: t('project.today'),- period: 'today',- tbs: ['hour'],- access: 'free',-}, {- label: t('project.yesterday'),- period: 'yesterday',- tbs: ['hour'],- access: 'free',-}, {- label: t('project.last24h'),- period: '1d',- tbs: ['hour'],- access: 'free',-}, {- label: t('project.lastXDays', { amount: 7 }),- period: '7d',- tbs: ['hour', 'day'],- access: 'free',-}, {- label: t('project.lastXWeeks', { amount: 4 }),- period: '4w',- tbs: ['day', 'week'],- access: 'free',-}, {- label: t('project.lastXMonths', { amount: 3 }),- period: '3M',- tbs: ['week', 'month'],- access: 'free',-}, {- label: t('project.lastXMonths', { amount: 12 }),- period: '12M',- tbs: ['week', 'month'],- access: 'paid',-}, {- label: t('project.lastXMonths', { amount: 24 }),- period: '24M',- tbs: ['month'],- access: 'paid',-}, {- label: getCustomLabel(dates, t),- dropdownLabel: t('project.custom'),- isCustomDate: true,- period: 'custom',- tbs: tbs || ['custom'],- access: 'free',-}]--// the order of panels in the project view-export const TRAFFIC_PANELS_ORDER = ['cc', 'pg', 'lc', 'br', 'os', 'dv', 'ref', 'so', 'me', 'ca']-export const PERFORMANCE_PANELS_ORDER = ['cc', 'pg', 'br', 'dv']--// the maximum amount of months user can go back when picking a date in flat picker (project view)-export const MAX_MONTHS_IN_PAST = 24-export const MAX_MONTHS_IN_PAST_FREE = 3--export const timeBucketToDays = [- { lt: 1, tb: ['hour'] }, // 1 days- { lt: 7, tb: ['hour', 'day'] }, // 7 days- { lt: 28, tb: ['day', 'week'] }, // 4 weeks- { lt: 366, tb: ['week', 'month'] }, // 12 months- { lt: 732, tb: ['month'] }, // 24 months-]--export const tbsFormatMapper = {- hour: '%d %b %H:%M',- day: '%d %b',- week: '%d %b',- month: '%d %b %Y',-}--export const tbsFormatMapper24h = {- hour: '%H:%M',- day: '%d %b',- week: '%d %b',- month: '%d %b %Y',-}--export const TimeFormat = {- '12-hour': '12-hour',- '24-hour': '24-hour',-}--export const FREE_TIER_KEY = 'free'--// a dedicated variable is needed for paid tier checking-export const WEEKLY_REPORT_FREQUENCY = 'weekly'-export const reportFrequencies = [WEEKLY_REPORT_FREQUENCY, 'monthly', 'quarterly', 'never']--export const reportFrequencyForEmailsOptions = [- { value: 'quarterly', label: 'Quarterly' },- { value: 'monthly', label: 'Monthly' },- { value: 'weekly', label: 'Weekly' },- { value: 'never', label: 'Never' },-]--export const GDPR_EXPORT_TIMEFRAME = 14 // days--export const SHOW_BANNER_AT_PERC = 85 // show banner when 85% of events in tier are used--export const TITLE_SUFFIX = '| Swetrix'--export const LS_THEME_SETTING = 'colour-theme'-export const LS_VIEW_PREFS_SETTING = 'proj-view-preferences'-export const LS_CAPTCHA_VIEW_PREFS_SETTING = 'captcha-view-preferences'--export const DEFAULT_TIMEZONE = 'Etc/GMT'--export const DONATE_URL = 'https://ko-fi.com/andriir'-export const FIREFOX_ADDON_URL = 'https://addons.mozilla.org/en-US/firefox/addon/swetrix/'-export const CHROME_EXTENSION_URL = 'https://chrome.google.com/webstore/detail/swetrix/glbeclfdldjldjonfnpnembfkhphmeld'-export const HAVE_I_BEEN_PWNED_URL = 'https://haveibeenpwned.com/passwords'-export const LINKEDIN_URL = 'https://www.linkedin.com/company/swetrix/'-export const GITHUB_URL = 'https://github.com/Swetrix'-export const TWITTER_URL = 'https://twitter.com/intent/user?screen_name=swetrix'-export const TWITTER_USERNAME = '@swetrix'-export const DISCORD_URL = 'https://discord.gg/tVxGxU3s4B'-export const STATUSPAGE_URL = 'https://stats.uptimerobot.com/33rvmiXXEz'-export const BLOG_URL = 'https://blog.swetrix.com'-export const UTM_GENERATOR_URL = 'https://url.swetrix.com'-export const MARKETPLACE_URL = 'https://marketplace.swetrix.com'-export const DOCS_URL = 'https://docs.swetrix.com'-export const CAPTCHA_URL = 'https://captcha.swetrix.com'-export const DOCS_CAPTCHA_URL = `${DOCS_URL}/captcha/introduction`-export const CDN_URL = process.env.REACT_APP_CDN_URL--// Swetrix vs ...-export const SWETRIX_VS_GOOGLE = 'https://blog.swetrix.com/post/vs-google-analytics/'-export const SWETRIX_VS_CLOUDFLARE = 'https://blog.swetrix.com/post/vs-cloudflare-analytics/'-export const SWETRIX_VS_SIMPLE_ANALYTICS = 'https://blog.swetrix.com/post/vs-simple-analytics/'--export const isDevelopment = !process.env.NODE_ENV || process.env.NODE_ENV === 'development'--export const SUPPORTED_THEMES = ['light', 'dark']--export const CONTACT_EMAIL = '[email protected]'-export const SECURITY_EMAIL = '[email protected]'--export const isSelfhosted = Boolean(process.env.REACT_APP_SELFHOSTED)--export const LIVE_VISITORS_UPDATE_INTERVAL = 40000-export const GENERAL_STATS_UPDATE_INTERVAL = 60000--// Functions-export const getProjectCacheKey = (period: string, timeBucket: string) => `${period}${timeBucket}`-export const getProjectCaptchaCacheKey = (period: string, timeBucket: string) => `${period}${timeBucket}captcha`-export const getProjectForcastCacheKey = (period: string, timeBucket: string, periodToForecast: string) => `${period}${timeBucket}${periodToForecast}forecast`-export const getProjectCacheCustomKey = (from: string, to: string, timeBucket: string) => `${from}-${to}-${timeBucket}`--// Cookies-export const GDPR_REQUEST = 'gdpr_request'-export const CONFIRMATION_TIMEOUT = 'confirmation_timeout'-export const LOW_EVENTS_WARNING = 'low_events_warning'-export const TOKEN = 'access_token'-export const REFRESH_TOKEN = 'refresh_token'--// List of languages with translations available-export const whitelist = ['en', 'uk', 'pl', 'de', 'sv', 'el', 'ru', 'hi', 'zh']-export const defaultLanguage = 'en'-export const languages = {- en: 'English',- uk: 'Українська',- pl: 'Polski',- de: 'Deutsch',- sv: 'Svenska',- el: 'Ελληνικά',- ru: 'Русский',- hi: 'हिन्दी',- zh: '中文简体',-}--export const languageFlag = {- en: 'GB',- uk: 'UA',- pl: 'PL',- de: 'DE',- sv: 'SE',- el: 'GR',- ru: 'RU',- hi: 'IN',- zh: 'CN',-}--export const paddleLanguageMapping = {- zh: 'zh-Hans',- uk: 'ru',- el: 'en',-}--// dashboard && projects--export const roles = ['admin', 'viewer']--export const roleViewer = {- name: 'Viewer',- role: 'viewer',- description: 'Can view the project',-}--export const roleAdmin = {- name: 'Admin',- role: 'admin',- description: 'Can manage the project',-}--export const tabForOwnedProject = 'owned'-export const tabForSharedProject = 'shared'-export const tabForCaptchaProject = 'captcha'--export const tabsForDashboard = [- {- name: tabForOwnedProject,- label: 'profileSettings.owned',- },- {- name: tabForSharedProject,- label: 'profileSettings.shared',- },- {- name: tabForCaptchaProject,- label: 'profileSettings.captcha',- },-]--export const PROJECT_TABS = {- traffic: 'traffic',- performance: 'performance',- alerts: 'alerts',-}--export const DASHBOARD_TABS = {- owned: 'owned',- shared: 'shared',- captcha: 'captcha',-}--export const QUERY_METRIC = {- PAGE_VIEWS: 'page_views',- UNIQUE_PAGE_VIEWS: 'unique_page_views',- ONLINE_USERS: 'online_users',-}--export const QUERY_CONDITION = {- GREATER_THAN: 'greater_than',- GREATER_EQUAL_THAN: 'greater_equal_than',- LESS_THAN: 'less_than',- LESS_EQUAL_THAN: 'less_equal_than',-}--export const QUERY_TIME = {- LAST_15_MINUTES: 'last_15_minutes',- LAST_30_MINUTES: 'last_30_minutes',- LAST_1_HOUR: 'last_1_hour',- LAST_4_HOURS: 'last_4_hours',- LAST_24_HOURS: 'last_24_hours',- LAST_48_HOURS: 'last_48_hours',-}--export const INVITATION_EXPIRES_IN = 48 // hours-export const ENTRIES_PER_PAGE_DASHBOARD = 10--export const THEME_TYPE = {- classic: 'classic',- christmas: 'christmas',-}--export const DEFAULT_ALERTS_TAKE = 100--// TODO: Eventually this should be fetched from the API, e.g. GET /config route-export const PLAN_LIMITS = {- free: {- priceMonthly: 0,- priceYearly: 0,- monthlyUsageLimit: 5000,- maxProjects: 10,- maxAlerts: 1,- legacy: true,- },- trial: {- monthlyUsageLimit: 100000,- maxProjects: 20,- maxAlerts: 20,- legacy: false,- priceMonthly: 0,- priceYearly: 0,- },- hobby: {- monthlyUsageLimit: 10000,- maxProjects: 20,- maxAlerts: 10,- legacy: false,- priceMonthly: 5,- priceYearly: 50,- },- freelancer: {- monthlyUsageLimit: 100000,- maxProjects: 20,- maxAlerts: 20,- legacy: false,- priceMonthly: 15,- priceYearly: 150,- },- startup: {- monthlyUsageLimit: 1000000,- maxProjects: 30,- maxAlerts: 50,- legacy: false,- priceMonthly: 59,- priceYearly: 590,- },- enterprise: {- monthlyUsageLimit: 5000000,- maxProjects: 50,- maxAlerts: 100,- legacy: false,- priceMonthly: 110,- priceYearly: 1100,- },-}--export const TRIAL_DAYS = 14--export const chartTypes = {- line: 'line',- bar: 'bar',-}diff --git a/src/redux3/reducers/alerts.js b/src/redux3/reducers/alerts.jsdeleted file mode 100644index ad46b983e..000000000--- a/src/redux3/reducers/alerts.js+++ /dev/null@@ -1,31 +0,0 @@-import { types } from 'redux/actions/alerts/types'--const initialState = {- message: null,- type: 'info',-}--// eslint-disable-next-line default-param-last-const alertsReducer = (state = initialState, { type, payload }) => {- switch (type) {- case types.ACCOUNT_DELETED:- case types.ACCOUNT_UPDATED:- case types.NEW_PASSWORD:- case types.DELETE_PROJECT_SUCCESS:- case types.CREATE_NEW_PROJECT_SUCCESS:- case types.ROLE_UPDATED:- case types.INVITE_USER:- case types.REMOVE_USER:- case types.USER_SHARED_UPDATE:- case types.GENERATE_ALERTS:- return { ...state, message: payload.message, type: payload.type }-- case types.CLEAR_ALERTS:- return { ...state, message: null, type: 'info' }-- default:- return state- }-}--export default alertsReducerdiff --git a/src/redux3/reducers/auth.js b/src/redux3/reducers/auth.jsdeleted file mode 100644index 9bb669daa..000000000--- a/src/redux3/reducers/auth.js+++ /dev/null@@ -1,107 +0,0 @@-import { types } from 'redux/actions/auth/types'-import _filter from 'lodash/filter'-import _map from 'lodash/map'-import { FREE_TIER_KEY, isSelfhosted } from '../constants'--const initialState = {- redirectPath: null,- authenticated: false,- loading: true,- user: {},- dontRemember: false,- // if the app is selfhosted, we assume that the user is using a paid tier so there won't be any restrictions or advertising of it- isPaidTierUsed: isSelfhosted,-}--// eslint-disable-next-line default-param-last-const authReducer = (state = initialState, { type, payload }) => {- switch (type) {- case types.SIGNUP_UP_SUCCESSFUL:- case types.LOGIN_SUCCESSFUL: {- const { user } = payload-- return {- ...state,- user: payload.user,- authenticated: true,- isPaidTierUsed: isSelfhosted || (user?.planCode && user.planCode !== FREE_TIER_KEY),- }- }-- case types.UPDATE_USER_PROFILE_SUCCESS:- return { ...state, user: payload.user }-- case types.EMAIL_VERIFY_SUCCESSFUL:- return { ...state, user: { ...state.user, isActive: true } }-- case types.SET_USER: {- const { user } = payload- return {- ...state,- user: {- ...state.user,- ...user,- },- }- }-- case types.SAVE_PATH:- return { ...state, redirectPath: payload.path }-- case types.SET_API_KEY:- return { ...state, user: { ...state.user, apiKey: payload.apiKey } }-- case types.LOGOUT:- case types.DELETE_ACCOUNT_SUCCESS:- return { ...state, authenticated: false, user: {} }-- case types.FINISH_LOADING:- return { ...state, loading: false }-- case types.DELETE_SHARE_PROJECT: {- // eslint-disable-next-line no-case-declarations- const { id } = payload- return { ...state, user: { ...state.user, sharedProjects: _filter(state.user.sharedProjects, (item) => item.id !== id) } }- }-- case types.SET_DONT_REMEMBER: {- const { dontRemember } = payload- return { ...state, dontRemember }- }-- case types.UPDATE_USER_DATA: {- const { data } = payload-- return {- ...state,- user: {- ...state.user,- ...data,- },- }- }-- case types.SET_USER_SHARE_DATA: {- // eslint-disable-next-line no-case-declarations- const { data, id } = payload- return {- ...state,- user: {- ...state.user,- sharedProjects: _map(state.user.sharedProjects, (item) => {- if (item.id === id) {- return { ...item, ...data }- }-- return item- }),- },- }- }-- default:- return state- }-}--export default authReducerdiff --git a/src/redux3/reducers/errors.ts b/src/redux3/reducers/errors.tsdeleted file mode 100644index c04635001..000000000--- a/src/redux3/reducers/errors.ts+++ /dev/null@@ -1,35 +0,0 @@-import { types } from 'redux/actions/errors/types'--interface initialStateInterface {- error: string | null-}--const initialState: initialStateInterface = {- error: null,-}--// eslint-disable-next-line default-param-last-const errorsReducer = (state = initialState, { type, payload }) => {- switch (type) {- case types.GENERIC_ERROR:- case types.LOGIN_FAILED:- case types.SIGN_UP_FAILED:- case types.UPDATE_USER_PROFILE_FAILED:- case types.CREATE_NEW_PASSWORD_FAILED:- case types.DELETE_ACCOUNT_FAILED:- case types.CREATE_NEW_PROJECT_FAILED:- case types.UPDATE_PROJECT_FAILED:- case types.DELETE_PROJECT_FAILED:- case types.GDPR_EXPORT_FAILED:- case types.SHARED_PROJECT_FAILED:- return { ...state, error: payload.error }-- case types.CLEAR_ERRORS:- return { ...state, error: null }-- default:- return state- }-}--export default errorsReducerdiff --git a/src/redux3/reducers/index.ts b/src/redux3/reducers/index.tsdeleted file mode 100644index 40fbbbcac..000000000--- a/src/redux3/reducers/index.ts+++ /dev/null@@ -1,9 +0,0 @@-import { combineReducers } from 'redux'-import auth from './auth'-import errors from './errors'-import alerts from './alerts'-import ui from './ui'--export default combineReducers({- auth, errors, alerts, ui,-})diff --git a/src/redux3/reducers/ui/alerts.js b/src/redux3/reducers/ui/alerts.jsdeleted file mode 100644index 7cf808b34..000000000--- a/src/redux3/reducers/ui/alerts.js+++ /dev/null@@ -1,48 +0,0 @@-import { types } from 'redux/actions/ui/types'--const getInitialState = () => {- return {- alerts: [],- total: 0,- pageTotal: 0,- loading: false,- }-}--// eslint-disable-next-line default-param-last-const alertsReducer = (state = getInitialState(), { type, payload }) => {- switch (type) {- case types.SET_PROJECT_ALERTS: {- const { alerts } = payload-- return {- ...state,- alerts,- }- }-- case types.SET_PROJECT_ALERTS_TOTAL: {- const { total, pageTotal } = payload-- return {- ...state,- total,- pageTotal,- }- }-- case types.SET_PROJECT_ALERTS_LOADING: {- const { loading } = payload-- return {- ...state,- loading,- }- }-- default:- return state- }-}--export default alertsReducerdiff --git a/src/redux3/reducers/ui/cache.js b/src/redux3/reducers/ui/cache.jsdeleted file mode 100644index 9654378a6..000000000--- a/src/redux3/reducers/ui/cache.js+++ /dev/null@@ -1,226 +0,0 @@-import { types } from 'redux/actions/ui/types'-import _filter from 'lodash/filter'-import _isEmpty from 'lodash/isEmpty'--import {- getProjectCacheKey, LS_VIEW_PREFS_SETTING, LS_CAPTCHA_VIEW_PREFS_SETTING, getProjectCaptchaCacheKey,-} from 'redux/constants'--export const getInitialViewPrefs = (LS_VIEW) => {- if (typeof window !== 'undefined' && window.localStorage) {- const storedPrefs = window.localStorage.getItem(LS_VIEW)- if (typeof storedPrefs === 'string') {- try {- return JSON.parse(storedPrefs)- } catch (e) {- window.localStorage.removeItem(LS_VIEW)- }- }- }-- return {}-}--const getInitialState = () => {- return {- // { pid: { 'period + timeBucket': { ... }, ... }, ... }- // example: { 'FSMaC9V4HFLA': { '4wday': { }, '7dhour': { } } }- analytics: {},-- analyticsPerf: {},-- captchaAnalytics: {},-- captchaProjectsViewPrefs: getInitialViewPrefs(LS_CAPTCHA_VIEW_PREFS_SETTING),-- // { pid: { period: '7d', timeBucket: 'day' }, ... }- projectViewPrefs: getInitialViewPrefs(LS_VIEW_PREFS_SETTING),- }-}--// eslint-disable-next-line default-param-last-const cacheReducer = (state = getInitialState(), { type, payload }) => {- switch (type) {- case types.SET_PROJECT_CACHE: {- const { pid, data, key } = payload-- return {- ...state,- analytics: {- ...state.analytics,- [pid]: {- ...state.analytics[pid],- [key]: data,- },- },- }- }-- case types.SET_CAPTCHA_PROJECT_CACHE: {- const { pid, data, key } = payload-- return {- ...state,- captchaAnalytics: {- ...state.captchaAnalytics,- [pid]: {- ...state.captchaAnalytics[pid],- [key]: data,- },- },- }- }-- case types.DELETE_PROJECT_CACHE: {- const { pid, period, timeBucket } = payload- const key = getProjectCacheKey(period, timeBucket)-- if (_isEmpty(period) || _isEmpty(timeBucket)) {- if (_isEmpty(pid)) {- return {- ...state,- analytics: {},- }- }-- return {- ...state,- analytics: _filter(state.analytics, (project) => project !== pid),- }- }-- return {- ...state,- analytics: {- ...state.analytics,- [pid]: _filter(state.analytics[pid], (ckey) => ckey !== key),- },- }- }-- case types.DELETE_CAPTCHA_PROJECT_CACHE: {- const { pid, period, timeBucket } = payload- const key = getProjectCaptchaCacheKey(period, timeBucket)-- if (_isEmpty(period) || _isEmpty(timeBucket)) {- if (_isEmpty(pid)) {- return {- ...state,- captchaAnalytics: {},- }- }-- return {- ...state,- captchaAnalytics: _filter(state.captchaAnalytics, (project) => project !== pid),- }- }-- return {- ...state,- captchaAnalytics: {- ...state.captchaAnalytics,- [pid]: _filter(state.captchaAnalytics[pid], (ckey) => ckey !== key),- },- }- }-- case types.SET_PROJECT_VIEW_PREFS: {- const {- pid, period, timeBucket, rangeDate,- } = payload-- return {- ...state,- projectViewPrefs: {- ...state.projectViewPrefs,- [pid]: rangeDate ? {- period, timeBucket, rangeDate,- } : {- period, timeBucket,- },- },- }- }-- case types.SET_CAPTCHA_PROJECTS_VIEW_PREFS: {- const {- pid, period, timeBucket, rangeDate,- } = payload-- return {- ...state,- captchaProjectsViewPrefs: {- ...state.captchaProjectsViewPrefs,- [pid]: rangeDate ? {- period, timeBucket, rangeDate,- } : {- period, timeBucket,- },- },- }- }-- case types.SET_PROJECT_CACHE_PERF: {- const { pid, data, key } = payload-- return {- ...state,- analyticsPerf: {- ...state.analyticsPerf,- [pid]: {- ...state.analyticsPerf[pid],- [key]: data,- },- },- }- }-- case types.DELETE_PROJECT_CACHE_PERF: {- const { pid, period, timeBucket } = payload- const key = getProjectCacheKey(period, timeBucket)-- if (_isEmpty(period) || _isEmpty(timeBucket)) {- if (_isEmpty(pid)) {- return {- ...state,- analyticsPerf: {},- }- }-- return {- ...state,- analyticsPerf: _filter(state.analyticsPerf, (project) => project !== pid),- }- }-- return {- ...state,- analyticsPerf: {- ...state.analyticsPerf,- [pid]: _filter(state.analyticsPerf[pid], (ckey) => ckey !== key),- },- }- }-- case types.SET_PROJECT_FORECAST_CACHE: {- const { pid, data, key } = payload-- return {- ...state,- analytics: {- ...state.analytics,- [pid]: {- ...state.analytics[pid],- [key]: data,- },- },- }- }-- default:- return state- }-}--export default cacheReducerdiff --git a/src/redux3/reducers/ui/index.js b/src/redux3/reducers/ui/index.jsdeleted file mode 100644index 8a3d0ad92..000000000--- a/src/redux3/reducers/ui/index.js+++ /dev/null@@ -1,10 +0,0 @@-import { combineReducers } from 'redux'-import projects from './projects'-import cache from './cache'-import theme from './theme'-import misc from './misc'-import alerts from './alerts'--export default combineReducers({- projects, cache, theme, misc, alerts,-})diff --git a/src/redux3/reducers/ui/misc.js b/src/redux3/reducers/ui/misc.jsdeleted file mode 100644index 9bb1388f7..000000000--- a/src/redux3/reducers/ui/misc.js+++ /dev/null@@ -1,81 +0,0 @@-import { types } from 'redux/actions/ui/types'-import { LOW_EVENTS_WARNING } from 'redux/constants'-import { setCookie } from 'utils/cookie'-import { secondsTillNextMonth } from 'utils/generic'--const initialState = {- stats: {- users: 0,- projects: 0,- pageviews: 0,- },- paddle: {- lastEvent: null,- },- showNoEventsLeftBanner: false,- lastBlogPost: {},- extensions: [],-}--// eslint-disable-next-line default-param-last-const miscReducer = (state = initialState, { type, payload }) => {- switch (type) {- case types.SET_GENERAL_STATS: {- const { stats } = payload-- return {- ...state,- stats,- }- }-- case types.SET_PADDLE_LAST_EVENT: {- const { event } = payload-- return {- ...state,- paddle: {- ...state.paddle,- lastEvent: event,- },- }- }-- case types.SET_SHOW_NO_EVENTS_LEFT: {- const { showNoEventsLeftBanner } = payload-- if (!showNoEventsLeftBanner) {- const maxAge = secondsTillNextMonth() + 86400- setCookie(LOW_EVENTS_WARNING, 1, maxAge)- }-- return {- ...state,- showNoEventsLeftBanner,- }- }-- case types.SET_EXTENSIONS: {- const { extensions } = payload-- return {- ...state,- extensions,- }- }-- case types.SET_LAST_BLOG_POST: {- const { lastBlogPost } = payload-- return {- ...state,- lastBlogPost,- }- }-- default:- return state- }-}--export default miscReducerdiff --git a/src/redux3/reducers/ui/projects.js b/src/redux3/reducers/ui/projects.jsdeleted file mode 100644index 532a74aff..000000000--- a/src/redux3/reducers/ui/projects.js+++ /dev/null@@ -1,322 +0,0 @@-import { types } from 'redux/actions/ui/types'-import _filter from 'lodash/filter'-import _findIndex from 'lodash/findIndex'-import _map from 'lodash/map'-import { tabForOwnedProject, PROJECT_TABS } from 'redux/constants'-import { setItem, getItem } from 'utils/localstorage'--const getInitialState = () => {- return {- projects: [],- sharedProjects: [],- captchaProjects: [],- isLoading: true,- isLoadingShared: true,- isLoadingCaptcha: true,- error: null,- totalMonthlyEvents: null,- total: 0,- sharedTotal: 0,- captchaTotal: 0,- dashboardPaginationPage: 1,- dashboardPaginationPageShared: 1,- dashboardPaginationPageCaptcha: 1,- dashboardTabs: getItem('dashboardTabs') || tabForOwnedProject,- projectTab: PROJECT_TABS.traffic,- alerts: [],- subscribers: [],- }-}--// eslint-disable-next-line default-param-last-const projectsReducer = (state = getInitialState(), { type, payload }) => {- switch (type) {- case types.SET_PROJECTS: {- const { projects, shared = false } = payload- if (shared) {- return {- ...state,- isLoadingShared: false,- sharedProjects: projects,- }- }-- return {- ...state,- projects,- isLoading: false,- }- }-- case types.SET_CAPTCHA_PROJECTS: {- const { captchaProjects } = payload- return {- ...state,- captchaProjects,- isLoadingCaptcha: false,- }- }-- case types.SET_DASHBOARD_PAGINATION_PAGE: {- const { page } = payload- return {- ...state,- dashboardPaginationPage: page,- }- }-- case types.SET_DASHBOARD_PAGINATION_PAGE_SHARED: {- const { page } = payload- return {- ...state,- dashboardPaginationPageShared: page,- }- }-- case types.SET_DASHBOARD_PAGINATION_PAGE_CAPTCHA: {- const { page } = payload- return {- ...state,- dashboardPaginationPageCaptcha: page,- }- }-- case types.SET_TOTAL_MONTHLY_EVENTS: {- const { totalMonthlyEvents } = payload- return {- ...state,- totalMonthlyEvents,- }- }-- case types.SET_TOTAL: {- const { total, shared } = payload-- if (shared) {- return {- ...state,- sharedTotal: total,- }- }-- return {- ...state,- total,- }- }-- case types.SET_CAPTCHA_PROJECTS_TOTAL: {- const { total } = payload- return {- ...state,- captchaTotal: total,- }- }-- case types.SET_CAPTCHA_PROJECTS_LOADING: {- const { isLoading } = payload- return {- ...state,- isLoadingCaptcha: isLoading,- }- }-- case types.REMOVE_CAPTCHA_PROJECT: {- const { id } = payload- return {- ...state,- captchaProjects: _filter(state.captchaProjects, (el) => el.id !== id),- }- }-- case types.SET_LIVE_STATS: {- const { data, shared = false } = payload-- if (shared) {- return {- ...state,- sharedProjects: _map(state.sharedProjects, res => ({- ...res,- project: {- ...res.project,- live: data[res.project.id],- },- })),- }- }-- return {- ...state,- projects: _map(state.projects, res => ({- ...res,- live: data[res.id],- })),- }- }-- case types.SET_LIVE_STATS_PROJECT: {- const { id, count, shared = false } = payload-- if (shared) {- return {- ...state,- sharedProjects: _map(state.sharedProjects, res => {- if (res.id === id) {- return {- ...res,- live: count,- }- }-- return res- }),- }- }-- return {- ...state,- projects: _map(state.projects, res => {- if (res.id === id) {- return {- ...res,- live: count,- }- }-- return res- }),- }- }-- case types.SET_PUBLIC_PROJECT: {- const { project, shared = false } = payload-- if (shared) {- return {- ...state,- sharedProjects: _findIndex(state.sharedProjects, (el) => el.id === project.id) >= 0- ? state.sharedProjects- : [- ...state.sharedProjects,- {- ...project,- uiHidden: true,- },- ],- }- }-- return {- ...state,- projects: _findIndex(state.projects, (el) => el.id === project.id) >= 0- ? state.projects- : [- ...state.projects,- {- ...project,- uiHidden: true,- },- ],- }- }-- case types.SET_PROJECTS_SHARE_DATA: {- const { data, id, shared = false } = payload-- if (shared) {- return {- ...state,- sharedProjects: _map(state.sharedProjects, (item) => {- if (item.project.id === id) {- return {- ...item,- ...data,- }- }-- return item- }),- }- }-- return {- ...state,- projects: _map(state.projects, (item) => {- if (item.id === id) {- return {- ...item,- ...data,- }- }-- return item- }),- }- }-- case types.SET_PROJECTS_ERROR: {- const { error } = payload- return {- ...state,- error,- }- }-- case types.REMOVE_PROJECT: {- const { pid, shared = false } = payload-- if (shared) {- return {- ...state,- sharedProjects: _filter(state.sharedProjects, (item) => item.project.id !== pid),- sharedTotal: state.sharedTotal - 1,- }- }-- return {- ...state,- projects: _filter(state.projects, (project) => project.id !== pid),- total: state.total - 1,- }- }-- case types.SET_PROJECTS_LOADING: {- const { isLoading, shared = false } = payload- if (shared) {- return {- ...state,- isLoadingShared: isLoading,- }- }- return {- ...state,- isLoading,- }- }-- case types.SET_DASHBOARD_TABS: {- const { tab } = payload-- setItem('dashboardTabs', tab)-- return {- ...state,- dashboardTabs: tab,- }- }-- case types.SET_PROJECT_TAB: {- const { tab } = payload-- return {- ...state,- projectTab: tab,- }- }-- default:- return state- }-}--export default projectsReducerdiff --git a/src/redux3/reducers/ui/theme.js b/src/redux3/reducers/ui/theme.jsdeleted file mode 100644index 738b2b119..000000000--- a/src/redux3/reducers/ui/theme.js+++ /dev/null@@ -1,72 +0,0 @@-import _includes from 'lodash/includes'-import { types } from 'redux/actions/ui/types'-import { LS_THEME_SETTING, SUPPORTED_THEMES, THEME_TYPE } from 'redux/constants'--const setThemeToDOM = (theme) => {- const root = window.document.documentElement- const isDark = theme === 'dark'-- root.classList.remove(isDark ? 'light' : 'dark')- root.classList.add(theme)-}--const setTheme = (theme) => {- setThemeToDOM(theme)- localStorage.setItem(LS_THEME_SETTING, theme)- return theme-}--const getInitialTheme = () => {- if (typeof window !== 'undefined' && window.localStorage) {- const lsTheme = window.localStorage.getItem(LS_THEME_SETTING)- if (_includes(SUPPORTED_THEMES, lsTheme)) {- setThemeToDOM(lsTheme)- return lsTheme- }-- const userMedia = window.matchMedia('(prefers-color-scheme: dark)')- if (userMedia.matches) {- setThemeToDOM('dark')- return 'dark'- }- }-- setThemeToDOM('light')- return 'light' // light theme as the default-}--const getInitialState = () => {- return {- theme: getInitialTheme(),- type: THEME_TYPE.classic,- }-}--// eslint-disable-next-line default-param-last-const themeReducer = (state = getInitialState(), { type, payload }) => {- switch (type) {- case types.SET_THEME: {- const { theme } = payload-- setTheme(theme)- return {- ...state,- theme,- }- }-- case types.SET_THEME_TYPE: {- const { theme } = payload-- return {- ...state,- type: theme,- }- }-- default:- return state- }-}--export default themeReducerdiff --git a/src/redux3/sagas/auth/watchers/index.js b/src/redux3/sagas/auth/watchers/index.jsdeleted file mode 100644index 0e3cb93b7..000000000--- a/src/redux3/sagas/auth/watchers/index.js+++ /dev/null@@ -1,40 +0,0 @@-import { takeLatest, all, call } from 'redux-saga/effects'-import { types } from 'redux/actions/auth/types'-import signIn from 'redux/sagas/auth/workers/signin'-import signUp from 'redux/sagas/auth/workers/signup'-import logout from 'redux/sagas/auth/workers/logout'-import verifyEmail from 'redux/sagas/auth/workers/verifyEmail'-import updateUserProfile from 'redux/sagas/auth/workers/updateUserProfile'-import deleteUserAccount from 'redux/sagas/auth/workers/deleteUserAccount'--function* watchLogin() {- yield takeLatest(types.LOGIN_ASYNC, signIn)-}--function* watchVerifyEmail() {- yield takeLatest(types.EMAIL_VERIFY_ASYNC, verifyEmail)-}--function* watchSignup() {- yield takeLatest(types.SIGNUP_ASYNC, signUp)-}--function* watchLogout() {- yield takeLatest(types.LOGOUT, logout)-}--function* watchUpdateUserProfile() {- yield takeLatest(types.UPDATE_USER_PROFILE_ASYNC, updateUserProfile)-}--function* watchDeleteUserProfile() {- yield takeLatest(types.DELETE_ACCOUNT_ASYNC, deleteUserAccount)-}--export default function* watchAuth() {- yield all([- call(watchLogin), call(watchSignup), call(watchVerifyEmail),- call(watchUpdateUserProfile), call(watchDeleteUserProfile),- call(watchLogout),- ])-}diff --git a/src/redux3/sagas/auth/workers/deleteUserAccount.js b/src/redux3/sagas/auth/workers/deleteUserAccount.jsdeleted file mode 100644index 1d1a09466..000000000--- a/src/redux3/sagas/auth/workers/deleteUserAccount.js+++ /dev/null@@ -1,26 +0,0 @@-import { call, put } from 'redux-saga/effects'--import { authActions } from 'redux/actions/auth'-import { alertsActions } from 'redux/actions/alerts'-import { deleteUser } from 'api'--export default function* deleteUserAccountWorker({ payload: { errorCallback, successCallback, t } }) {- try {- yield call(deleteUser)- yield call(successCallback)- yield put(authActions.deleteAccountSuccess())- yield put(alertsActions.accountDeleted(t('apiNotifications.accountDeleted')))- } catch (error) {- let message-- try {- message = JSON.parse(error.message).message || 'somethingWentWrong'- } catch (e) {- message = 'somethingWentWrong'- }-- errorCallback(t([`apiNotifications.${message}`, 'apiNotifications.somethingWentWrong']))- } finally {- yield put(authActions.finishLoading())- }-}diff --git a/src/redux3/sagas/auth/workers/updateUserProfile.js b/src/redux3/sagas/auth/workers/updateUserProfile.jsdeleted file mode 100644index aada1db8d..000000000--- a/src/redux3/sagas/auth/workers/updateUserProfile.js+++ /dev/null@@ -1,20 +0,0 @@-import { call, put } from 'redux-saga/effects'--import { authActions } from 'redux/actions/auth'-import { errorsActions } from 'redux/actions/errors'-import { changeUserDetails } from 'api'--export default function* updateUserProfileWorker({ payload: { data, callback } }) {- let isSuccess = false- try {- const user = yield call(changeUserDetails, data)-- yield put(authActions.updateProfileSuccess(user))- isSuccess = true- } catch (error) {- yield put(errorsActions.updateProfileFailed(error.message || (typeof error === 'string' ? error : error[0])))- } finally {- yield put(authActions.finishLoading())- callback(isSuccess)- }-}diff --git a/src/redux3/sagas/auth/workers/verifyEmail.js b/src/redux3/sagas/auth/workers/verifyEmail.jsdeleted file mode 100644index 5ca09fdb8..000000000--- a/src/redux3/sagas/auth/workers/verifyEmail.js+++ /dev/null@@ -1,16 +0,0 @@-import { call, put } from 'redux-saga/effects'--import { authActions } from 'redux/actions/auth'-import { verifyEmail } from 'api'--export default function* verifyEmailWorker({ payload: { data, successfulCallback, errorCallback } }) {- try {- yield call(verifyEmail, data)- yield put(authActions.emailVerifySuccess())- successfulCallback()- } catch (error) {- errorCallback(error)- } finally {- yield put(authActions.finishLoading())- }-}diff --git a/src/redux3/sagas/index.js b/src/redux3/sagas/index.jsdeleted file mode 100644index 8287aea30..000000000--- a/src/redux3/sagas/index.js+++ /dev/null@@ -1,8 +0,0 @@-import { fork } from 'redux-saga/effects'-import watchAuth from './auth/watchers'-import uiSaga from './ui'--export default function* rootSaga() {- yield fork(watchAuth)- yield fork(uiSaga)-}diff --git a/src/redux3/sagas/ui/initialise.js b/src/redux3/sagas/ui/initialise.jsdeleted file mode 100644index ce9ac621e..000000000--- a/src/redux3/sagas/ui/initialise.js+++ /dev/null@@ -1,29 +0,0 @@-import { put, call } from 'redux-saga/effects'-import Debug from 'debug'--import { getAccessToken } from 'utils/accessToken'-import { getRefreshToken } from 'utils/refreshToken'-import { getLastPost } from 'api/blog'-import UIActions from 'redux/actions/ui'--const debug = Debug('swetrix:rx:s:initialise')--export default function* initialise() {- try {- const token = yield call(getAccessToken)- const refreshToken = yield call(getRefreshToken)-- if (token && refreshToken) {- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- yield put(UIActions.loadProjectsCaptcha())- yield put(UIActions.loadExtensions())- yield put(UIActions.loadProjectAlerts())- }-- const lastBlogPost = yield call(getLastPost)- yield put(UIActions.setLastBlogPost(lastBlogPost))- } catch (e) {- debug('An error occured whilst initialising: %s', e)- }-}diff --git a/src/redux3/sagas/ui/load_forecast.js b/src/redux3/sagas/ui/load_forecast.jsdeleted file mode 100644index e69de29bb..000000000diff --git a/src/redux3/sagas/ui/load_shared_projects.js b/src/redux3/sagas/ui/load_shared_projects.jsdeleted file mode 100644index 494c7a14a..000000000--- a/src/redux3/sagas/ui/load_shared_projects.js+++ /dev/null@@ -1,66 +0,0 @@-import { put, call } from 'redux-saga/effects'-import _map from 'lodash/map'-import _isString from 'lodash/isString'-import Debug from 'debug'--import UIActions from 'redux/actions/ui'--import { ENTRIES_PER_PAGE_DASHBOARD } from 'redux/constants'-import {- getSharedProjects, getOverallStats, getLiveVisitors,-} from '../../../api'--const debug = Debug('swetrix:rx:s:load-projects')--export default function* loadSharedProjects({ payload: { take = ENTRIES_PER_PAGE_DASHBOARD, skip = 0 } }) {- try {- yield put(UIActions.setProjectsLoading(true, true))-- let {- // eslint-disable-next-line prefer-const- results, total,- } = yield call(getSharedProjects, take, skip)-- if (total === 0) {- return- }-- const projectsWithShared = _map(results, (result) => {- return {- ...result,- project: {- ...result.project,- shared: true,- },- }- })- const pids = _map(projectsWithShared, ({ project }) => project.id)-- let overall-- try {- overall = yield call(getOverallStats, pids)- } catch (e) {- debug('failed to overall stats: %s', e)- }-- results = _map(projectsWithShared, res => ({- ...res,- project: {- ...res.project,- overall: overall?.[res.project.id],- },- }))-- yield put(UIActions.setProjects(results, true))- yield put(UIActions.setTotal(total, true))-- const liveStats = yield call(getLiveVisitors, pids)- yield put(UIActions.setLiveStats(liveStats, true))- } catch ({ message }) {- if (_isString(message)) {- yield put(UIActions.setProjectsError(message))- }- debug('failed to load shared projects: %s', message)- }-}diff --git a/src/redux3/sagas/ui/logout.js b/src/redux3/sagas/ui/logout.jsdeleted file mode 100644index cb661f35c..000000000--- a/src/redux3/sagas/ui/logout.js+++ /dev/null@@ -1,11 +0,0 @@-import { put } from 'redux-saga/effects'--import UIActions from 'redux/actions/ui'--export default function* logout() {- yield put(UIActions.setProjects([]))- yield put(UIActions.setProjects([], true))- yield put(UIActions.setTotal(0))- yield put(UIActions.setTotal(0, true))- yield put(UIActions.deleteProjectCache())-}diff --git a/src/redux3/sagas/ui/set_project_view_prefs.js b/src/redux3/sagas/ui/set_project_view_prefs.jsdeleted file mode 100644index 7bdc3cfa5..000000000--- a/src/redux3/sagas/ui/set_project_view_prefs.js+++ /dev/null@@ -1,21 +0,0 @@-import { LS_VIEW_PREFS_SETTING } from 'redux/constants'-import { getInitialViewPrefs } from 'redux/reducers/ui/cache'--export default function setProjectViewPrefs({- payload: {- pid, period, timeBucket, rangeDate,- },-}) {- if (typeof window !== 'undefined' && window.localStorage) {- const viewPrefs = {- ...getInitialViewPrefs(),- [pid]: rangeDate ? {- period, timeBucket, rangeDate,- } : {- period, timeBucket,- },- }-- window.localStorage.setItem(LS_VIEW_PREFS_SETTING, JSON.stringify(viewPrefs))- }-}diff --git a/src/redux3/sagas/ui/share_verify.js b/src/redux3/sagas/ui/share_verify.jsdeleted file mode 100644index 4bd036917..000000000--- a/src/redux3/sagas/ui/share_verify.js+++ /dev/null@@ -1,15 +0,0 @@-import { call, put } from 'redux-saga/effects'--import UIActions from 'redux/actions/ui'-import { verifyShare } from 'api'--export default function* shareVerify({ payload: { data, successfulCallback, errorCallback } }) {- try {- yield call(verifyShare, data)- yield put(UIActions.loadProjects())- yield put(UIActions.loadSharedProjects())- successfulCallback()- } catch (error) {- errorCallback(error)- }-}diff --git a/src/redux3/store/index.ts b/src/redux3/store/index.tsdeleted file mode 100644index 857c5d1cc..000000000--- a/src/redux3/store/index.ts+++ /dev/null@@ -1,15 +0,0 @@-import { createStore, applyMiddleware, compose } from 'redux'-import createSagaMiddleware from 'redux-saga'-import rootReducer from 'redux/reducers'-import rootSaga from 'redux/sagas'--// @ts-ignore-const composeEnhancers = window?.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose-const sagaMiddleware = createSagaMiddleware()--export const store = createStore(- rootReducer,- composeEnhancers(applyMiddleware(sagaMiddleware)),-)--sagaMiddleware.run(rootSaga)diff --git a/src/redux3/types/IAuth.ts b/src/redux3/types/IAuth.tsdeleted file mode 100644index 99ebe9b8d..000000000--- a/src/redux3/types/IAuth.ts+++ /dev/null@@ -1,7 +0,0 @@-import { IUser } from './IUser'--export interface IAuth {- refresh_token: string- access_token: string- user: IUser-}diff --git a/src/redux3/types/IProject.ts b/src/redux3/types/IProject.tsdeleted file mode 100644index 7f77a7a88..000000000--- a/src/redux3/types/IProject.ts+++ /dev/null@@ -1,37 +0,0 @@-export interface IOverall {- thisWeek: number- lastWeek: number- thisWeekUnique: number- lastWeekUnique: number-}--export interface IUserShareProject {- email: string-}--export interface IShareOwnerProject {- id: string- confirmed: boolean- role: string- created: string- updated: string- user: IUserShareProject-}--export interface IProject {- id: string- name: string- origins: string[]- ipBlacklist: string[] | null- active: boolean- public: boolean- isAnalyticsProject: boolean- isCaptchaProject: boolean- isCaptchaEnabled: boolean- captchaSecretKey: string | null- created: string- share: IShareOwnerProject[]- isOwner: boolean- overall: IOverall- live: number-}diff --git a/src/redux3/types/ISharedProject.ts b/src/redux3/types/ISharedProject.tsdeleted file mode 100644index 46f4dfe29..000000000--- a/src/redux3/types/ISharedProject.ts+++ /dev/null@@ -1,10 +0,0 @@-import { IProject } from './IProject'--export interface ISharedProject {- id: string- confirmed: boolean- role: string- created: string- updated: string- project: IProject-}diff --git a/src/redux3/types/IUser.ts b/src/redux3/types/IUser.tsdeleted file mode 100644index 8d0bf7624..000000000--- a/src/redux3/types/IUser.ts+++ /dev/null@@ -1,32 +0,0 @@-import { ISharedProject } from './ISharedProject'--export interface IUser {- id: string- roles: string[]- planCode: string- nickname: string- email: string- isActive: boolean- trialEndDate: string- reportFrequency: string- emailRequests: number- created: string- updated: string- evWarningSentOn: string | null- exportedAt: string- subID: string | null- subUpdateURL: string | null- subCancelURL: string | null- timezone: string- theme: string | null- isTwoFactorAuthenticationEnabled: boolean- trialReminderSent: boolean- billingFrequency: string | null- nextBillDate: string | null- cancellationEffectiveDate: string | null- apiKey: string | null- telegramChatId: string- isTelegramChatIdConfirmed: boolean- timeFormat: string- sharedProjects: ISharedProject[]-}