diff --git a/apps/ligretto-frontend/src/app/store/rootSaga.ts b/apps/ligretto-frontend/src/app/store/rootSaga.ts index 2d37567e..874f3186 100644 --- a/apps/ligretto-frontend/src/app/store/rootSaga.ts +++ b/apps/ligretto-frontend/src/app/store/rootSaga.ts @@ -4,10 +4,9 @@ import { socketSaga } from '#entities/socket' import { gameRootSaga } from '#ducks/game' import { usersRootSaga } from '#ducks/users' import { authRootSaga, getMeSuccess } from '#ducks/auth' -import { analyticsRootSaga } from '#ducks/analytics/sagas' export default function* rootSaga() { - yield all([fork(analyticsRootSaga), fork(gameRootSaga), fork(authRootSaga), fork(usersRootSaga), fork(blockedSocketSaga)]) + yield all([fork(gameRootSaga), fork(authRootSaga), fork(usersRootSaga), fork(blockedSocketSaga)]) } function* blockedSocketSaga() { diff --git a/apps/ligretto-frontend/src/ducks/analytics/actions.ts b/apps/ligretto-frontend/src/ducks/analytics/actions.ts deleted file mode 100644 index e0be21bd..00000000 --- a/apps/ligretto-frontend/src/ducks/analytics/actions.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createAction } from '@reduxjs/toolkit' - -export const logAnalyticsEventAction = createAction<{ eventType: string } & { eventProperties?: Record }>( - '@@analytics/logAnalyticsEventAction', -) diff --git a/apps/ligretto-frontend/src/ducks/analytics/analytics.ts b/apps/ligretto-frontend/src/ducks/analytics/analytics.ts deleted file mode 100644 index 95ae076c..00000000 --- a/apps/ligretto-frontend/src/ducks/analytics/analytics.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Analytics } from '@memebattle/analytics' -import { AMPLITUDE_TOKEN } from '#shared/constants/config' - -export const analytics = new Analytics({ apiKey: AMPLITUDE_TOKEN }) diff --git a/apps/ligretto-frontend/src/ducks/analytics/index.ts b/apps/ligretto-frontend/src/ducks/analytics/index.ts deleted file mode 100644 index fe8eadec..00000000 --- a/apps/ligretto-frontend/src/ducks/analytics/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './sagas' -export * from './actions' diff --git a/apps/ligretto-frontend/src/ducks/analytics/sagas.ts b/apps/ligretto-frontend/src/ducks/analytics/sagas.ts deleted file mode 100644 index 46324b75..00000000 --- a/apps/ligretto-frontend/src/ducks/analytics/sagas.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { takeEvery, takeLatest } from 'redux-saga/effects' - -import { getMeSuccess } from '#ducks/auth' - -import { analytics } from './analytics' -import { logAnalyticsEventAction } from './actions' - -export function* analyticsRootSaga() { - analytics.logEvent('Init application') - - yield takeLatest(getMeSuccess, ({ payload }) => { - analytics.setUserProperties({ id: payload.userId, isTemporary: payload.isTemporary }) - analytics.logEvent('User authorized') - }) - - yield takeEvery(logAnalyticsEventAction, ({ payload: { eventType, eventProperties } }) => { - analytics.logEvent(eventType, eventProperties) - }) -} diff --git a/apps/ligretto-frontend/src/ducks/auth/authSagas.ts b/apps/ligretto-frontend/src/ducks/auth/authSagas.ts index 79e00638..054a0b3a 100644 --- a/apps/ligretto-frontend/src/ducks/auth/authSagas.ts +++ b/apps/ligretto-frontend/src/ducks/auth/authSagas.ts @@ -8,6 +8,8 @@ import type { User } from '../users/usersTypes' import { logout, getMeRequest, getMeSuccess } from './authActions' import { LOCAL_STORAGE_TOKEN_KEY } from './constants' +import { analytics } from '#entities/analytics' + export function* initSaga() { const token = window.localStorage.getItem(LOCAL_STORAGE_TOKEN_KEY) ?? undefined yield put(getMeRequest({ token })) @@ -25,6 +27,10 @@ export function* getMeSaga({ payload }: ReturnType) { username: user?.username, }) window.localStorage.setItem(LOCAL_STORAGE_TOKEN_KEY, user.token) + + analytics.setUserProperties({ id: user.userId, isTemporary: user.isTemporary }) + analytics.logEvent('User authorized') + yield put(getMeSuccess({ ...user })) } diff --git a/apps/ligretto-frontend/src/ducks/game/sagas.ts b/apps/ligretto-frontend/src/ducks/game/sagas.ts index db55476d..939829ea 100644 --- a/apps/ligretto-frontend/src/ducks/game/sagas.ts +++ b/apps/ligretto-frontend/src/ducks/game/sagas.ts @@ -36,20 +36,6 @@ import { socketConnectedAction } from '#entities/socket' import { locationSelector } from '#ducks/router' import { connectToRoomAction } from '#ducks/rooms' -function* gameUpdateSaga(action: ReturnType) { - const game = action.payload - yield put(updateGameSliceAction(game)) -} - -function* togglePlayerStatusSaga() { - const currentStatus: ReturnType = yield select(playerStatusSelector) - const gameId: ReturnType = yield select(gameIdSelector) - - const status = currentStatus === PlayerStatus.DontReadyToPlay ? PlayerStatus.ReadyToPlay : PlayerStatus.DontReadyToPlay - - yield put(setPlayerStatusEmitAction({ status, gameId })) -} - function* connectToRoomSuccessSaga(action: ReturnType) { yield put(updateGameSliceAction(action.payload.game)) yield put(setGameLoadedAction(true)) @@ -157,8 +143,6 @@ function* handleLocationChangeSaga() { } export function* gameRootSaga() { - yield takeLatest(updateGameAction, gameUpdateSaga) - yield takeLatest(togglePlayerStatusAction, togglePlayerStatusSaga) yield takeLatest(startGameAction, startGameSaga) yield takeEvery(tapCardAction, tapCardSaga) yield takeEvery(tapStackOpenDeckCardAction, tapStackOpenDeckCardActionSaga) diff --git a/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/index.ts b/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/index.ts deleted file mode 100644 index edb5b8f6..00000000 --- a/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './useAnalytics' diff --git a/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/useAnalytics.ts b/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/useAnalytics.ts deleted file mode 100644 index b9c9703c..00000000 --- a/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/useAnalytics.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { useDispatch } from 'react-redux' -import { useCallback } from 'react' - -import { logAnalyticsEventAction } from '#ducks/analytics' - -export const useAnalytics = () => { - const dispatch = useDispatch() - const logAnalyticsEvent = useCallback( - (eventType: string, eventProperties?: Record) => dispatch(logAnalyticsEventAction({ eventType, eventProperties })), - [dispatch], - ) - - return { logAnalyticsEvent } -}