mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 11:01:56 +02:00
[web] track email notification settings interactions (#32719)
* send setting-changed event * emit event for global mute notifications GitOrigin-RevId: 0705ffc331185e0f49fa1103e856040548d4f8bf
This commit is contained in:
@@ -3,6 +3,8 @@ import { useProjectContext } from '@/shared/context/project-context'
|
||||
import { getJSON, postJSON } from '@/infrastructure/fetch-json'
|
||||
import { debugConsole } from '@/utils/debugging'
|
||||
import type { NotificationPreferencesSchema } from '../../../../../modules/notifications/app/src/types.js'
|
||||
import { sendMB } from '@/infrastructure/event-tracking'
|
||||
import { useIdeReactContext } from '@/features/ide-react/context/ide-react-context'
|
||||
|
||||
export type NotificationLevel = 'all' | 'replies' | 'off'
|
||||
|
||||
@@ -83,6 +85,7 @@ function preferencesToLevel(
|
||||
|
||||
export function useProjectNotificationPreferences() {
|
||||
const { projectId } = useProjectContext()
|
||||
const { permissionsLevel } = useIdeReactContext()
|
||||
const [notificationLevel, setNotificationLevel] =
|
||||
useState<NotificationLevel>('all')
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
@@ -103,11 +106,16 @@ export function useProjectNotificationPreferences() {
|
||||
(level: NotificationLevel) => {
|
||||
setNotificationLevel(level)
|
||||
const preferences = levelToPreferences(level)
|
||||
sendMB('setting-changed', {
|
||||
changedSetting: 'projectEmailNotifications',
|
||||
changedSettingVal: level,
|
||||
projectRole: permissionsLevel,
|
||||
})
|
||||
postJSON(`/notifications/preferences/project/${projectId}`, {
|
||||
body: preferences,
|
||||
}).catch(debugConsole.error)
|
||||
},
|
||||
[projectId]
|
||||
[projectId, permissionsLevel]
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user